jeddi
11-04-2009, 02:45 PM
Hello,
I have the following code to find the $findme1 in the
text string.
What I want to do is to continue finding the finds until the end of the
string. So I have wrapped it with a while, but I am not sure what expression to use to make it continue until the end of the file
Now, before you write that I should use preg_match_all(), there is a reason for me wanting to skip a lot of the matches which is why I am locating the $findme1.
while( ???) {
$pos1 = strpos($text, $findme1, $off_set);
if ($pos1 === false) {
echo "<br>$findme1 not found";
exit();
}
$text = substr($text,$pos1);
preg_match("/href=\"(.*?)\"/",$text,$matches, PREG_OFFSET_CAPTURE);
print_r($matches);
$saved_url = $matches[1][0];
$off_set = $matches[1][1];
echo "<br><br><br>Match: $saved_url<br><br>";
$urls[] = $saved_url;
}
Oh - and if I use break: instaed of exit:, will the script continue on after the while loop ?
Thanks
I have the following code to find the $findme1 in the
text string.
What I want to do is to continue finding the finds until the end of the
string. So I have wrapped it with a while, but I am not sure what expression to use to make it continue until the end of the file
Now, before you write that I should use preg_match_all(), there is a reason for me wanting to skip a lot of the matches which is why I am locating the $findme1.
while( ???) {
$pos1 = strpos($text, $findme1, $off_set);
if ($pos1 === false) {
echo "<br>$findme1 not found";
exit();
}
$text = substr($text,$pos1);
preg_match("/href=\"(.*?)\"/",$text,$matches, PREG_OFFSET_CAPTURE);
print_r($matches);
$saved_url = $matches[1][0];
$off_set = $matches[1][1];
echo "<br><br><br>Match: $saved_url<br><br>";
$urls[] = $saved_url;
}
Oh - and if I use break: instaed of exit:, will the script continue on after the while loop ?
Thanks