PHP extract all whole numbers into an array

前端 未结 4 1156
清酒与你
清酒与你 2021-01-28 15:58

I have following string:

15 asdas 26 dasda 354 dasd 1

and all that i want is to extract all numbers from it into an array, so it will looks li

4条回答
  •  轮回少年
    2021-01-28 16:17

    $str = '15 asdas 26 dasda 354 dasd 1';
    preg_match_all('/\d+/', $str, $matches);
    print_r($matches);
    

提交回复
热议问题