note 27989 added to function.strstr
| From: | nin at screamingslaves dot com | Date: | Sat, 28 Dec 2002 18:54:11 +0000 |
| Subject: | note 27989 added to function.strstr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41393@lists.php.net to get a copy of this message | ||
Since I managed to do this in a few seconds, why not let it out to someone in the same need ...
Based on the above idea, since I had:
$string = "Some text (some note) some other text";
And say you just wanted whats *between* the parentheses (or between basically anything):
<?
function remover($string, $sep1, $sep2)
{
$string = substr($string, 0, strpos($string,$sep2));
$string = substr(strstr($string, $sep1), 1);
return $string;
}
$string = "Some text (some note) some other text";
$str1 = "(";
$str2 = ")";
echo remover($string, $str1, $str2);
?>
--
http://www.php.net/manual/en/function.strstr.php
http://master.php.net/manage/user-notes.php?action=edit+27989
http://master.php.net/manage/user-notes.php?action=delete+27989
http://master.php.net/manage/user-notes.php?action=reject+27989