php - Cutting out a specific part of a string using simple_html_dom? -


i use following code cut out div site.

$url = 'http://mypage.com/index.php'; $html = @file_get_html($url); $getscore = $html->find('div[class=ismsbvalue]',0); echo $getscore; 

this returns.....

<div class="ismsbvalue">     <div>   58         <sub>pts</sub>                                          </div> </div> 

how cut out 58 value?

i can following...

$getscore = $html  ->find('div[class=ismsbvalue]',0)   ->find('div',0)    ->innertext; 

to down this....

   58     <sub>pts</sub> 

is there way exclude <sub> tag using simple_html_dom? or stuck using str_replace() or strpos() cut further?

clone delete u dont want

javascript

$(function(){ var = $('.ismsbvalue').clone();     a.find('sub').remove();         console.log($.trim(a.text())); }) 

php

$html = str_get_html('<div class="ismsbvalue">     <div>   58         <sub>pts</sub>                                          </div> </div>');   $html->find('div[class=ismsbvalue]',0)->find('div',0)->find('sub',0)->innertext = ''; $a = $html->find('div[class=ismsbvalue]',0)->plaintext; echo trim($a); //58 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -