Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用简单的html dom替换结果中的短语和字符_Php_Html_Dom - Fatal编程技术网

Php 用简单的html dom替换结果中的短语和字符

Php 用简单的html dom替换结果中的短语和字符,php,html,dom,Php,Html,Dom,我的代码运行良好,使我从网上商店获得商品价格的外部部分,但加载了标准html、css和字母,我只想成为没有“,”的数字,或者“ABC”只是像“123”这样的数字 这是外部移动商店网站的一部分: <div class="prod-box-separation" style="padding-left:15px;padding-right:15px;text-align:center;padding-top:7px;"> <div style="color:#cc1515;"

我的代码运行良好,使我从网上商店获得商品价格的外部部分,但加载了标准html、css和字母,我只想成为没有“,”的数字,或者“ABC”只是像“123”这样的数字

这是外部移动商店网站的一部分:

<div class="prod-box-separation" style="padding-left:15px;padding-right:15px;text-align:center;padding-top:7px;">
   <div style="color:#cc1515;">
      <div class="price-box">
         <span class="regular-price" id="product-price-47488">
            <span >
               <span class="price">2.443,<sup>00</sup> RON</span>                                                    
            </span>
         </span>
      </div>
   </div>
</div>
<div class="prod-box-separation" style="padding-left:10px;padding-right:10px;">
   <style>
      .delivery {
     display:block;
      }
  </style>
  <p class="availability in-stock">
     <div class="stock_info">Produs in  stoc</div>
     <div class="delivery"><div class="delivery_title">Livrare(in timpul orelor de   program):</div>
     <div class="delivery_item">Bucuresti - BANEASA : imediat</div>
     <div  class="delivery_item">Bucuresti - EROILOR : luni dupa ora 13.00.</div>
     <div  class="delivery_item">CURIER : Marti</div>
  </div>
  </p>

2.443,00罗恩
.交货{
显示:块;
}

斯托克的普罗德斯 利夫雷沃(timpul Oreler de program中): Bucuresti-BANEASA:Imedia Bucuresti-EROILOR:luni dupa ora 13.00。 居里:马蒂

加兰尼:12卢尼

这是我的实际代码:

<?php
include_once('../simple_html_dom.php');
$dom = file_get_html("http://www.site.com/page.html");
// alternatively use str_get_html($html) if you have the html string already...
foreach ($dom->find('span[class=price]') as $node)
{
echo $node->innertext;
} 
?>   


我的结果是:
2.443,00 RON
但正确的结果是:
2.443
2443
你可以这样做:

<?php
include_once('../simple_html_dom.php');
$dom = file_get_html("http://www.site.com/page.html");
// alternatively use str_get_html($html) if you have the html string already...
foreach ($dom->find('span[class=price]') as $node)
{
$result = $node->innertext;
$price = explode(",<sup>", $result);
echo $price[0];
} 
?>