Page 1 of 1

strip data

Posted: Mon Sep 08, 2008 5:08 pm
by useradmn
hi everyone. im a newbie to the site and have a question:

does anyone know how to take data from a form and use only a certain portion of it.

Example, lets say someone enters 19 characters: "9885746234567891234" but I only want to use a certain portion of that. Lets say I only want to use "623456789" which is from the original string. So to sum it up, I want to skip the first six characters, use the next nine characters, and skip the last 4 characters.


Any help is greatly appreciated!


-Daniel

Re: strip data

Posted: Mon Sep 08, 2008 5:13 pm
by marcth
Something very similar to this should do the trick:

Code: Select all

 
$string = '9885746234567891234';
$subString = substr($string, 5, 9);
 
print $subString;
 
This link has all the documentation you'd ever want on the subject:
http://ca3.php.net/manual/en/function.substr.php