Jump to content

Archived

This topic is now archived and is closed to further replies.

becu

**SOLVED** How to search and pull out

Recommended Posts

ok, here's my problem:

$string = '<abc tag="test">sumtext goes here</abc>this is not supposed to show<abc>some more text goes here</abc>';

What should I do so I will only get everything inside [b]<abc[/b] and [b]</abc>[/b] tag?
preg_match didn't not work because it will pull out everything including "this is not supposed to show"
Thank you.

Share this post


Link to post
Share on other sites
Try
[code]
$string = '<abc tag="test">sumtext goes here</abc>this is not supposed to show<abc>some more text goes here</abc>';

$res = array();
$p3 = $p2 = 0;

while (($p1 = strpos($string, '<abc', $p3)) !== false) {
       $p2 = strpos($string,'>',$p1);
       $p3 = strpos($string,'</abc>',$p2);
       $res[] = substr($string,$p2+1, $p3-$p2-1);
}

echo join ('<br />', $res);[/code]

Share this post


Link to post
Share on other sites
Hi Barand,
Thank you so much for your help!
I really appreciate it!

Thanks again.

Have a great day! I will sure ask for help again :D

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.