note 73690 deleted from function.substr by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 07:16:26 +0000 |
| Subject: | note 73690 deleted from function.substr by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196701@lists.php.net to get a copy of this message | ||
Note Submitter: siavashg at gmail dot com
----
A further addition to Jean-Felix function to extract data between delimeters.
The previous function wouldn't return the correct data if the delimeters used where long than
one char. Instead the following function should do the job.
<?php
function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) {
$posLeft = stripos($inputstr,$delimeterLeft)+strlen($delimeterLeft);
$posRight = stripos($inputstr,$delimeterRight,$posLeft+1);
return substr($inputstr,$posLeft,$posRight-$posLeft);
}
?>