very simple regex not working
Posted: Sat Oct 13, 2007 7:14 am
feyd | Please use
the function returns false, however you can see that the pattern should match. Please help.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi all
I know i am missing something very small but would require your help in spotting out.
here is a small piece of code that does not work.Code: Select all
<?
function str_between($str,$start,$end) {
if (preg_match_all('/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/',$str,$matches)) {
return $matches[1];
}
// no matches
return "ttt";
}
/*$url="http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?mco=AA9C1548&nclm=CertifiedMac";
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
//curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
echo $data_mac = curl_exec ($ch);
curl_close ($ch);
*/
$data_mac = file_get_contents("http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?mco=AA9C1548&nclm=CertifiedMac");
//die();
$start='<td valign="top" class="details">';
$end='<p class="availability">';
echo $arr_data=str_between($data_mac,$start,$end);
foreach($arr_data as $var)
{
echo $var."<br>";
}
?>[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]