note 66950 deleted from function.substr by bjori

From: Date: Thu, 01 Jun 2006 15:32:47 +0000
Subject: note 66950 deleted from function.substr by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-112769@lists.php.net to get a copy of this message
Note Submitter: jasper at jtey dot com Reason: bad code ---- 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; } ?>

« previous php.notes (#112769) next »