note 45211 deleted from function.substr by bobby

From: Date: Thu, 14 Sep 2006 16:52:16 +0000
Subject: note 45211 deleted from function.substr by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117164@lists.php.net to get a copy of this message
Note Submitter: Gordon Axmann ---- Two very nice and practical functions: 1. Checks if a string ($needle) turns up at the BEGINNING of another string ($hay): 2. Checks if a string ($needle) appears at the END of another string ($hay): <?php function isstartstring($hay,$needle,$casesensitive=true) { // prüft ob ein string am Anfang vorkommt if (!$casesensitive) { $needle=strtolower($needle); $hay=strtolower($hay); } return (substr($hay,0,strlen($needle))==$needle); } function isendstring($hay,$needle,$casesensitiv=true) { // prüft ob ein string am Ende vorkommt if (!$casesensitive) { $needle=strtolower($needle); $hay=strtolower($hay); } return (substr($hay,-strlen($needle))==$needle); } ?>

« previous php.notes (#117164) next »