Is it possible to do a right to left search with strpos so for example I had the following variable $text = "abcdefghijklmnopqrstuvwxyz"; I could do a right to left search from z till I find p and the position it gives me is $x characters from z which would be 10.
Use strrpos: http://uk.php.net/manual/en/function.strrpos.php It counts from the start but you can simply subtract strlen and strrpos to get it form the end.
It's horrible to use for the first time, but once you got it you'll be cooking. There's some good examples in the comments on php.net IIRC. Good luck.
lol I wouldn't really say it's horrible. It's problems like this that make me enjoy programming so much.
I only ask people to give me the tools to solve the bigger picture. This particular job has taken about 16 hours work! lol