The strings always end with a hyphen followed by a variable size integer. For instance:
foo-bar-baz-132 another-55-string-961370
How can I remove the last hyphen (first occurrence from right to left) plus any character to the right?
try this
$string = 'foo-bar-baz-132 another-55-string-961370';
$result = substr ($string , 0, strrpos($string, '-'));
echo $result;
Source