Get the last word of a string

后端 未结 7 2306
时光说笑
时光说笑 2020-12-15 04:10

I have tried a few things to get a last part out I done this:

$string = \'Sim-only 500 | Internet 2500\';
preg_replace(\"Sim-Only ^([1-9]|[1-9][0-9]|[1-9][0-         


        
7条回答
  •  忘掉有多难
    2020-12-15 04:52

    If you want to wrap the last word with a span:

    ' . $pieces[count($pieces)-1] . '';
    
        // Returns the glued pieces
        return implode(" ", $pieces);
    }
    
    wrap_last_word('hello this is wrapped');
    // returns this:
    // hello this is wrapped
    

提交回复
热议问题