strip data

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
useradmn
Forum Newbie
Posts: 2
Joined: Mon Sep 08, 2008 5:04 pm

strip data

Post 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
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: strip data

Post 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
Post Reply