Gets the content before the specified string

$str = 'abc-efg'; $res = substr($str, 0, strrpos($str, '-')); echo $res; / / output ABCCopy the code

Gets the content after the specified string

$str = 'abc-efg'; $res = substr($str, strripos($AAA,"_")+1); echo $res; / / output efgCopy the code