PHP: Remove Everything Before and Including a Character/String

You are here

This can be achieved using string manipulation functions in PHP. First we find the position of the desired character in the string using strpos(), substr(), ltrim, and trim()

$new_name = substr($old_name, strpos($old_name, '_') + 1);

or

$new_name = ltrim(stristr($old_name, '_'), '_');