linein designs

29 Mar, 2007

Strip Off Characters from String Using PHP (substr)

Posted by: john In: php| programing

Here’s a quick way to strip off characters from a string using PHP’s function substr.

<?
$var = ‘05 Delete’;
$var = substr($var,0,2);
echo($var); // returns “05″
?>

If you wanted to strip off the characters from the end of a string, just change the “2″ to “-2″ and it will strip off the last two characters.

Similar Posts:

No related posts.

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post



Please Support Our Sponsors

A Payday advance can be a great way to get back on track.

Banner

About

My name is John Veldboom and have been in design and web programing for just over 8 years now. Started off as a hobby in high school but it has developed into a full time job now. I always tell people that if I wasn't doing this at work each day, I would be at home doing it for free. I love it!

Please visit the contact page to drop me a message.