note 45211 added to function.substr

From: Date: Mon, 30 Aug 2004 06:33:47 +0000
Subject: note 45211 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-75635@lists.php.net to get a copy of this message
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); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45211 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45211&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45211&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75635) next »