Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.