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 117 views
1 answer 109 views
1 answer 129 views
1 answer 114 views
1 answer 110 views
...