0

I am using PHP Simple HTML DOM Parser * [Manual] to fetch data from websites.
Now what i wanna do is to remove first three words from all span which has class="yeah" from the fetched content
So i have implement this code but it has a problem:

foreach($html->find('span.yeah') as $xdat)
{
$x_des = implode(' ', array_slice(explode(' ', strip_tags($xdat)), 0, 3));
$result = str_replace($x_des, ' ', $result);
$result = str_get_html($result);
}

Though it delete first three words from all <span class="yeah"> but the problem is, this modify full fetched content. But i wanna modify only those data whose are in <span class="yeah"> but it match first three words from all fetched data and then delete all of them, though i wanna remove those data from only those span types.
So, how to remove only first three words from all <span class="yeah"> </span> in the fetched content?

2
Contributors
2
Replies
5
Views
4 Years
Discussion Span
Last Post by rakibtg
0

@rakibtg

Though it delete first three words from all <span class="yeah"> but the problem is, this modify full fetched content. But i wanna modify only those data whose are in <span class="yeah"> but it match first three words from all fetched data and then delete all of them, though i wanna remove those data from only those span types. So, how to remove only first three words from all <span class="yeah"> </span> in the fetched content?

I'm not quite sure did you answer your own question:

http://stackoverflow.com/questions/13193701/how-to-get-first-three-words-of-a-span-class-in-php-simple-html-dom-parser

0

@LastMitch yeah! that's mine... can't get the answer so post it again here :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.