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.barbtest/b/a;
And I want to parse the string and extract everything between . Now if
the string only
SPLIT to the rescue! Split tears up your string into lists (arrays) which
you can cycle through and extract normaly. So this is going to look like
hell but here we go...
?
$str = a href=http://foo.barbtest/b/a;
$str_list1 = split ('', $str);
// Note: $str_list1 now == array (a
Thanks Kevin- yeah I guess I'll have to chop up the string.
David
- Original Message -
From: Kevin Stone [EMAIL PROTECTED]
To: David Yee [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, January 03, 2002 12:30 PM
Subject: Re: [PHP] find all the numeric positions of a character that
Here's the function I came up with- seems to work:
//finds all occurrences of $char in $temp and returns char positions in an
array
function char_positions($temp, $char)
{
while (strpos($temp, $char) !== FALSE){ //note the two '=='
$found = strpos($temp, $char);
$result[] =
4 matches
Mail list logo