note 17452 added to function.substr
| From: | bwhite at cch dot com dot au | Date: | Mon, 10 Dec 2001 03:42:09 +0000 |
| Subject: | note 17452 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-22420@lists.php.net to get a copy of this message | ||
One things the docs for this function doesn't make clear is that if
the $start >=0 and $length >= 0 and ( $start + $length ) > strlen( $str ), it will just
return any characters it has and the
string length will be less than $length.
This can actually be quite handy as it allows you to use
this function to set a maximum length for a string, eg:
<br> $str = substr( $str, 0, 10 ) // This forces $str to be a max of 10 chars
--
http://www.php.net/manual/en/function.substr.php
http://master.php.net/manage/user-notes.php?action=edit+17452
http://master.php.net/manage/user-notes.php?action=delete+17452
http://master.php.net/manage/user-notes.php?action=reject+17452