find all the numeric positions of a character that appears in a string multiple times
| From: | David Yee | Date: | Thu, 03 Jan 2002 20:11:29 +0000 |
| Subject: | find all the numeric positions of a character that appears in a string multiple times | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79353@lists.php.net to get a copy of this message | ||
Hi guys. What is the best way to find all the numeric positions of a
character that appears in a string multiple times? E.g. let's say I have
the following string:
$str = "<a href=http://foo.bar><b>test</b></a>";
And I want to parse the string and extract everything between <>. Now if
the string only had a single occurrence of "<" and ">" I can use strpos()
and substr() to extract it, but how do I do it for multiple occurrences? I
suppose I can keep chopping up the string to do this but I'm not sure if
that's the best way. Thanks.
David