Remove a string from the beginning of a string

后端 未结 11 2052
忘了有多久
忘了有多久 2020-11-28 06:30

I have a string that looks like this:

$str = \"bla_string_bla_bla_bla\";

How can I remove the first bla_; but only if it\'s fo

11条回答
  •  甜味超标
    2020-11-28 07:20

    function remove_prefix($text, $prefix) {
        if(0 === strpos($text, $prefix))
            $text = substr($text, strlen($prefix)).'';
        return $text;
    }
    

提交回复
热议问题