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:
- Find Time Between Two Dates in PHP
- UPDATED: Strip Off Characters from String Using PHP (substr)
- Quick PHP Function to Get File Sizes in KB, MB & GB
- MySQL Return Single Data or Single Array with PHP
- Turn 2D Array into a HTML Dropdown with PHP
No related posts.

No comments yet.