Get the characters before the last “-” (dash)

Solution:1

You’ll want to find the last occurrence of -, using strrpos().

$output = substr( $number, 0, strrpos( $number, '-' ) );

Solution:2

$part = substr($number,0,strrpos($number,"-"));

Solution:3

Use strrpos to find the last occurrence of -. Then use substr to get everything up to that point.

$lastPart = substr($number, 0, strrpos($number, '-'));