Splitting strings in PHP and get last part

前端 未结 13 2327
无人及你
无人及你 2020-12-08 04:39

I need to split a string in PHP by \"-\" and get the last part.

So from this:

abc-123-xyz-789

I expect to get

13条回答
  •  粉色の甜心
    2020-12-08 05:07

    You can use array_pop combined with explode

    Code:

    $string = 'abc-123-xyz-789';
    $output = array_pop(explode("-",$string));
    echo $output;
    

    DEMO: Click here

提交回复
热议问题