How to remove alphabets from an alphanumeric string in PHP

1 Answer

0 votes
$str = "c++ php 17 d 900 e 8542";

$pattern = '/[^0-9\s]/';

$str = preg_replace($pattern, "", $str);

echo $str;




/*
run:

  17  900  8542

*/

 



answered Nov 11, 2022 by avibootz

Related questions

1 answer 111 views
1 answer 100 views
1 answer 119 views
1 answer 106 views
1 answer 102 views
...