Jump to content

Using preg_match with strrpos


BSlepkov

Recommended Posts

The answer may be so simple that I've totally overlooked it, but I've been struggling to use preg_match with strrpos. Can it be done? If so, my coding would be a heck of a lot more efficient and elegant.

 

Basically, what I want to do is extract the first specific tag (<tr ... > or <li ... >) to the left of a string. The problem is not my regular express (#<(tr|li)[^<]*?>#i), just getting something like ...

    strrpos($some-xhtml-text, preg_match('#<(tr|li)[^<]*?>#i', $some-xhtml-text, $tag));

... to work.

 

Any takers?

 

Link to comment
https://forums.phpfreaks.com/topic/135337-using-preg_match-with-strrpos/
Share on other sites

since when is nesting functions elegant?

 

And anyways, that won't work, because preg_match returns the results in an array specified in the 3rd argument.  When you try to assign preg_match to something, it just assigns 1 for success, 0 for fail.

Archived

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

×
×
  • Create New...

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.