[PHP] find all the numeric positions of a character that appears in a string multiple times

2002-01-03 Thread David Yee
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

Re: [PHP] find all the numeric positions of a character that appears in a string multiple times

2002-01-03 Thread Kevin Stone
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

Re: [PHP] find all the numeric positions of a character that appears in a string multiple times

2002-01-03 Thread David Yee
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

Re: [PHP] find all the numeric positions of a character that appears in a string multiple times

2002-01-03 Thread David Yee
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[] =