note 66950 added to function.substr
| From: | jasperatjteydotcom at osu1 dot php dot net | Date: | Thu, 01 Jun 2006 14:55:05 +0000 |
| Subject: | note 66950 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112762@lists.php.net to get a copy of this message | ||
If you want a convenient function to determine if a string ends with something:
<?php
// Determine if str ends with suffix
function endsWith($str, $suffix){
return substr($str, strlen($str)-strlen($suffix)) == $suffix;
}
?>
Similarly, to determine if a string begins with something:
<?php
// Determine if str begins with prefix
function beginsWith($str, $prefix){
return substr($str, 0, strlen($prefix)) == $prefix;
}
?>
----
Server IP: 216.235.15.211
Probable Submitter: 69.159.216.64
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- http://master.php.net/note/edit/66950
Del: integrated -- http://master.php.net/note/delete/66950/integrated
Del: useless -- http://master.php.net/note/delete/66950/useless
Del: bad code -- http://master.php.net/note/delete/66950/bad+code
Del: spam -- http://master.php.net/note/delete/66950/spam
Del: non-english -- http://master.php.net/note/delete/66950/non-english
Del: in docs -- http://master.php.net/note/delete/66950/in+docs
Del: other reasons-- http://master.php.net/note/delete/66950
Reject -- http://master.php.net/note/reject/66950
Search -- http://master.php.net/manage/user-notes.php