note 28640 added to function.strchr

From: Date: Sun, 19 Jan 2003 04:39:16 +0000
Subject: note 28640 added to function.strchr
Groups: php.notes 
Request: Send a blank email to php-notes+get-42375@lists.php.net to get a copy of this message
joao's code works, but only if you want to get the text before the last occurence of the character. Here's another way that will output all the text before the first occurence. $stringA = "One Fish, Two Fish, Red Fish, Blue Fish"; $toFind = "Fish"; $result = str_replace( strchr($stringA, $toFind), "", $stringA); echo $result, $toFind; Will print "One Fish" Or Just: echo str_replace( strchr($stringA, $toFind), "", $stringA ), $toFind; -- http://www.php.net/manual/en/function.strchr.php http://master.php.net/manage/user-notes.php?action=edit+28640 http://master.php.net/manage/user-notes.php?action=delete+28640 http://master.php.net/manage/user-notes.php?action=reject+28640

« previous php.notes (#42375) next »