tags:

views:

52

answers:

4

How can I get everything from $string after "<div class='partFive'>"?

Thanks!

+2  A: 
saleemshafi
+1  A: 

Do you need everything after or everything in that DOM element?

I'm assuming you mean you want to grab everything in that DOM element, and the easiest way would be to grab it by using Zend_Dom.

http://framework.zend.com/manual/en/zend.dom.query.html

$dom = new Zend_Dom_Query($html); $results = $dom->query('div.partFive');

foreach ($results as $result) { // $result is a DOMElement }

Travis
He's only asking about strings.
Josh Leitzel
Yes, everyone always asks about processing HTML with strings and regex. Doesn't make it the right thing to do.
bobince
This could be useful but right now I just need to chop it.
Alex L
+1  A: 
$myString = strstr($string, "<div class='partFive'>");
The Disintegrator
This will include `"<div class='partFix'>"`. He wants everything after.
Josh Leitzel
is not that hard, simply add a substr then
The Disintegrator
A: 

You could just remove the part you don't want, like so:

$myString = str_replace("<div class='partFive'>","",$string);
Mike A.
What if the "<div class='partFive'>" was nested somehow, and the $string did not start with it?
Kevin D.
Sorry I didn't make it clear that the string does not start with that
Alex L