Page 1 of 1

Wanting to make VIN Decoder PHP script. Need help.

Posted: Sat Aug 16, 2003 10:34 am
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.

Posted: Sat Aug 16, 2003 3:21 pm
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);
?>