РЕДАКТИРОВАТЬ 2
Спасибо всем за помощь!
Объединив ответы и некоторые другие сообщения на форуме, мне удалось решить это:
$string = strip_tags($oNode['div.item-prijs']);
$array = str_split($string,1);
$arraytotal = ( $array[0] . ',' . $array[1] . $array[2] );
echo $arraytotal;
И показывает правильную цену сейчас. «7,49» PHP-скрипт, в который я автоматически преобразую.
Извините, что не могу дать больше ответов на вопросы. Дело закрыто.
Давай, ребята
$price = strip_tags($oNode['div.item-prijs']);
$new_price = substr(chunk_split($price, 1, ','), 0, -1);
echo $new_price;
Это будет эхо 7,4,9, а не 7,49. Но этот код пока самый лучший.
У кого-нибудь есть идеи как это исправить?
Ну, я пока застрял в этом ..
Я анализирую данные с веб-сайта и хочу узнать цену, но на веб-сайте нет запятой или точки между ценами. так что он показывает как 499, 4 больше, чем 99.
Когда я делаю:
$price = $oNode['div.item-prijs'];
echo $price;
Это будет эхом 499.
Я хочу добавить запятую или точку между 4 и 99.
Я пробовал:
$price = $oNode['div.item-prijs'];
$new_price = substr(chunk_split($price, 1, ','), 0, -1);
echo $new_string;
Это будет эхо:
<,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,7,<,s,u,p,>,4,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,4,<,s,u,p,>,9,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,1,<,s,u,p,>,4,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,0,<,s,u,p,>,6,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d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,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,0,<,s,u,p,>,9,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,1,<,s,u,p,>,4,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,2,<,s,u,p,>,0,8,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,1,<,s,u,p,>,4,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,3,<,s,u,p,>,4,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,6,<,s,u,p,>,1,8,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,3,<,s,u,p,>,9,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,4,<,s,u,p,>,2,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,><,d,i,v, ,c,l,a,s,s,=,",i,t,e,m,-,p,r,i,j,s,",>,<,p,>,2,<,s,u,p,>,7,9,<,/,s,u,p,>,<,/,p,>,<,/,d,i,v,>
А это:
$string = $oNode['div.item-prijs'];
$new_string = substr(chunk_split($string, 4, ','), 0, -1);
echo $new_string;
Это будет эхо:
,
7,49<,/sup,>,
<,/p><,/div,>,
4,99<,/sup,>,
1,49<,/sup,>,
0,69<,/sup,>,
1,99<,/sup,>,
1,49<,/sup,>,
1,49<,/sup,>,
3,49<,/sup,>,
3,49<,/sup,>,
3,69<,/sup,>,
1,19<,/sup,>,
1,89<,/sup,>,
1,99<,/sup,>,
1,99<,/sup,>,
1,49<,/sup,>,
2,99<,/sup,>,
1,99<,/sup,>,
1,09<,/sup,>,
2,25<,/sup,>,
1,99<,/sup,>,
0,99<,/sup,>,
1,54<,/sup,>,
2,09<,/sup,>,
1,78<,/sup,>,
1,71<,/sup,>,
0,99<,/sup,>,
1,49<,/sup,>,
2,08<,/sup,>,
1,49<,/sup,>,
3,49<,/sup,>,
6,18<,/sup,>,
3,99<,/sup,>,
4,29<,/sup,>,
2,79<,/sup,>
Таким образом, он будет обрабатывать каждую цену на странице, а также код HTML эха. Он разбивает HTML-код, а не только цену.
Ниже приведен HTML-код на сайте
<div class="item-prijs">
<p>
<cufon class="cufon cufon-canvas" alt="4" style="width: 27px; height: 42px; ">
<canvas width="47" height="43" style="width: 47px; height: 43px; top: -1px; left: -2px; "></canvas>
<cufontext>4</cufontext>
</cufon>
<sup>
<cufon class="cufon cufon-canvas" alt="99" style="width: 24px; height: 20px; ">
<canvas width="35" height="21" style="width: 35px; height: 21px; top: -1px; left: -1px; ">
</canvas><cufontext>99</cufontext>
</cufon>
</sup>
</p>
</div>
Что я делаю не так? Я пробовал разные способы, но безуспешно. Может кто-нибудь помочь мне с правильным кодом?
Спасибо