PHP split string into integer element and string

后端 未结 5 1889
小蘑菇
小蘑菇 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:35

    You can also do it using preg_split by splitting your input at the point which between the digits and the letters:

    list($num,$alpha) = preg_split('/(?<=\d)(?=[a-z]+)/i',$Order_num);
    

    See it

提交回复
热议问题