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?

Recommended Answers

All 2 Replies

Member Avatar for LastMitch

@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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.