I would like to see if the there is a way to do this without preg_replace, just string functions.
I am using this
$str = "-41d3vUYHtK3D-GI3QXiVhvfR-zNooU7U_--2697";
preg_replace("/\-\d+$/i","",$str)
to remove everything that follows and including the last “dash”
If it is not a requirement that the last characters have to be digits, then you can use
substr[docs] andstrrpos[docs]:Or in PHP 5.3.0,
strstr[docs]:If, on the other hand, you want to remove the last dash and characters only if the following characters are digits, then using regular expressions would be the easier way.