crawl page content - get data between string


function get_all_string_between($string, $start, $end)
{  
    $result = array();
    $string = " ".$string;
    $offset = 0;
    $grr = 0;
    while($grr<100)
    {
        $ini = strpos($string,$start,$offset);
        if ($ini == 0)
            break; 
        $ini += strlen($start);

        $len = strpos($string,$end,$ini) - $ini;
        $result[] = substr($string,$ini,$len);
        $offset = $ini+$len;
        $grr++;
    }
   
    return $result[0];
}

$url =' ';
$string_html = file_get_contents($url);

                $start_point1 = '<span class="price">$';
                $end_point1 = '</span>';

                $tmpfiles = get_all_string_between($string_html, $start_point1, $end_point1);

Comments

Popular Posts