note 81335 deleted from function.substr by peehaa
| From: | peehaa@php.net | Date: | Mon, 28 Nov 2016 19:54:30 +0000 |
| Subject: | note 81335 deleted from function.substr by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207723@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
I've used the between, after, before, etc functions that biohazard put together for years and
they work great. I've also added to it a new function that I use a lot and thought others
might like it as well. It uses his before/after functions so they are required to use it.
<?php
$example_html = "<p>test1 Test2</p><title>hi
there</title><p>Testing</p>";
$paragraph_text = multi_between('<p>', '</p>', $example_html);
//Prints an arry of:
//Array ( [1] => test1 Test2 [2] => Testing )
print_r($paragraph_text);
function multi_between($this, $that, $inthat)
{
$counter = 0;
while ($inthat)
{
$counter++;
$elements[$counter] = before($that, $inthat);
$elements[$counter] = after($this, $elements[$counter]);
$inthat = after($that, $inthat);
}
return $elements;
}
//Get the help functions from biohazard's post below.
?>