note 73540 deleted from function.substr by danbrown

From: Date: Mon, 20 Jun 2011 15:27:40 +0000
Subject: note 73540 deleted from function.substr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180767@lists.php.net to get a copy of this message
Note Submitter: Jean-Felix, Bern ---- If you need to extract information in a string between delimeters then you can use this: Inputstring is: "Heidi Klum Supermodel" <info@HeidiKlum.com> Here the script <?php $emailadresse = "\"Heidi Klum Supermodel\" <info@HeidiKlum.com>"; $outputvalue = extractBetweenDelimeters($emailadresse,"\"","\""); echo $outputvalue; // shows Heidi Klum Supermodel echo "<br>"; $outputvalue = extractBetweenDelimeters($emailadresse,"<",">"); echo $outputvalue; // shows info@HeidiKlum.com function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) { $posLeft = stripos($inputstr,$delimeterLeft)+1; $posRight = stripos($inputstr,$delimeterRight,$posLeft+1); return substr($inputstr,$posLeft,$posRight-$posLeft); } ?>

« previous php.notes (#180767) next »