Wanting to make VIN Decoder PHP script. Need help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Wanting to make VIN Decoder PHP script. Need help.

Post by camarosource »

Hello.

I am wanting to make a VIN Decoder PHP script for my site. This would consist of a single html form that would ask for the VIN number of a Camaro. The script would then need to look at each character of the vin (including verifying it's a certain number of characters) and depending on what characters were typed, would print the results of each in a seperate page.

IE. If I person typed the following as their VIN number : 1G1FP2385NL555555

The script would look verify a certain number of chars were typed (ie. 17), and then would read each character starting with "1". 1 would represent a certain result, then "G" which too would result into a certain result, then "1" again... and continue to the end of the VIN number.

What PHP commands would I be using to do the above? And what PHP commands can verify the number of charecters entered in a form field and be able to read each and distinguish charecters typed in a single form field?

Thanks.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Code: Select all

<?
$_GET['vin'] = "1G1FP2385NL555555";
$vin = $_GET['vin'];

echo strlen($vin); /* Will return "17" (string length) */
echo substr($vin,0,2); /* Will return "1G" */
echo substr($vin,2,3); /* Will return "1FP" */
echo substr($vin,11,6); /* Will return "555555" */
echo substr($vin,5,4); /* Will return "2385" */
?>

The syntax for substr() is:

substr ( $string , where to start from , how many characters to take );

So to echo "ell", I could type

Code: Select all

<?
echo substr("Hello",1,3);
?>
Post Reply