php remove string from beginning of a string if exists code example Example: php remove prefix from string $str = preg_replace('/^bla_/', '', $str);