note 28640 deleted from function.strchr by bjori

From: Date: Tue, 11 Apr 2006 20:37:33 +0000
Subject: note 28640 deleted from function.strchr by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107802@lists.php.net to get a copy of this message
Note Submitter: webmaster at gamestyle dot net ---- 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;

« previous php.notes (#107802) next »