note 15744 modified in function.substr-replace by zak
| From: | zak@php.net | Date: | Sat, 29 Sep 2001 00:46:23 +0000 |
| Subject: | note 15744 modified in function.substr-replace by zak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-18429@lists.php.net to get a copy of this message | ||
If you would like to remove characters from the start or end of a string, try the substr() function.
For example, to remove the last three characters from a string:
$string = "To be or not to be.";
$string = substr ($string, 0, -3);
--was--
To remove the last two characters of any string, use this:
<?php
$pos = strlen($var) - 2;
$var = substr_replace($var, '', $pos, 2);
?>
http://www.php.net/manual/en/function.substr-replace.php