I love the SUBSTRING_INDEX function in MySQL, especially because you can use negative indexes to start searching from the right side of the string.
Is there an equiv
I think
string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
is the right php function for you.
strstr — Finds the first occurrence of a string