The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Thanks Son Nguyen for trying, but unless I'm missing something, this doesn't do it. It returns total length of string + 1, with the example I gave.

I'd imagine that the reason why strrpos() permits just 1 character is bcs it requires quite a bit of effort to locate the last occurrence with a simple function? (especially as haystack could be much bigger with many more occurrences of the string)

1 way I've thought of is to 1st replace all the occurrences of the string with 1 character and then use strrpos() to find the position.

But, the problem is generating a unique character that doesn't clash. Please assume, that the contents of $string may or may not be known before-hand.

Therefore, another check would be needed to make sure this character is uniwue and doesn't already occur in then string. If it does then try another character, and so on.

why dont you just write your own function similar to strpos, but instead of searching for a single character, it will give you the llast position of a group of chracters, using the builtin substr function.

One catch this would work but your original example:
$haystack = 'start<LI>middle<LI>ending<>';
would just return <> since it is the last occurence of <

the result of strpos and strrpos is merely a reference to the spot in the haystack where the first or last occurence of needle starts so it will always return a number. What exactly are trying to accomplish it is possible that you may be going about it in the wrong way.

Please don't PM me with questions.
Use the forums, that is what they are here for.