I have this string abc_123_test and I am trying to get just "test" from the string. I have this code currently.
$string = 'abc_123_test';
$extracted_string = substr( $string, 0, strrpos( $string, '_' ) );
However this gets the first part of the string, everything up to 'abc_123'. So it seems it is reverse of what I wanted. I thought by using strrpos, it will get the reversed but obviously I am missing something.
Any help?
strrpos(), it's withsubstr(). Read the documentation.