PHP split string into integer element and string

后端 未结 5 1897
小蘑菇
小蘑菇 2020-11-30 11:09

I have a string say: Order_num = \"0982asdlkj\"

How can I split that into the 2 variables, with the number element and then another variable with the le

5条回答
  •  不知归路
    2020-11-30 11:42

    You can use a regex for that.

    preg_match('/(\d{1,4})([a-z]+)/i', $str, $matches);
    array_shift($matches);
    list($num, $alpha) = $matches;
    

提交回复
热议问题