New users seek php regular expression to get the number $ x & quot; 123xadg2hj5ed & quot; I want to retrieve all the other digits in $ x. thank you for your help. $ Str & quot; 5555555ddd & quot; ereg (& quot; [0-9] & quot;, $ str, $ a); echo $; I cannot write it like this. ------ Solution -------------------- preg_m beginners seek php regular expression to get numbers
$ X = "123xadg2hj5ed ";
I want to retrieve all the other numbers in $ x. thank you for your help.
$ Str = "5555555ddd ";
Ereg ("[0-9]", $ str, $ );
Echo $;
I cannot write it like this.
------ Solution --------------------
Preg_match ("/[0-9] +/", $ str, $ );
------ Solution --------------------
$ Str = "5555555ddd ";
Ereg ("[0-9] +", $ str, $ );
Print_r ($ a); // Array ([0] = & gt; 5555555)
$ Str = "123xadg2hj5ed ";
Preg_match_all ("/[0-9] +/", $ str, $ );
Print_r ($ a); // Array ([0] => Array ([0] => 123 [1] => 2 [2] => 5 ))
------ Solution --------------------
PHP code