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
See this Demo
This solution use is_numeric function :
print_r(array_filter(split(" ", "15 asdas 26 dasda 354 dasd 1"),"is_numeric"));
This solution use your own function :
function is_number($var) { return !(0 == intval($var)); }
print_r(array_filter(split(" ", "15 asdas 26 dasda 354 dasd 1"),"is_number"));
To 5.3.0 and more, this solution use preg_split function :
print_r(array_filter(preg_split(" ", "15 asdas 26 dasda 354 dasd 1"),"is_numeric"));