Php正则表达式结果错误

时间:2015-10-16 12:42:07

标签: php preg-match

我应该从这个网站获得价格,这里我正在使用PHP正则表达式和cUrl。

网址=' http://www.shopclues.com/lenovo-a526-with-1-year-physical-liquid-damage-cover-plus-insurance-refurbished.html';

$shopclues = get_page($url); 
if(preg_match('#<div class="price"><label>Deal Price:</label>(.*?)<\/div>#is', $shopclues,$b)) {
            $data['price'] = (float) str_replace(array(','),'',$b[1]);
        }
        elseif(preg_match('#<span id="sec_discounted_price_5713954">(.*?)<\/span><\/div>#is', $shopclues,$a))
        {
    $data['price'] = (float) str_replace(array(','),'',$a[1]);
        }

1 个答案:

答案 0 :(得分:-1)

由此行解决

$data['price'] = (float) str_replace(array('Rs.', ','),'',$b[1]);