I'm looking to store all number's that occur alone in a string. The integers must occur on their own and be surrounded by white space.
Here's what I mean:
Input
blah 5 blah bl3h 555 blah 123 blah a2b3 5030a
Expected Output
[5], [555], [123]
Here's my attempted iterator that seems to group the current word correctly but adds nothing to the array
//$a = String
function numberReturn($a){
$currWord;
$numberArray = array();
//Loop through string
for($i = 0; $i < strlen($a); $i++){
//Keep adding chars to current word
$currWord .= $a[$i];
//if white space check if current word is only numeric
//if only numbers add it to array
//when added, clear current word
if(ctype_space($a[$i])){
if(is_numeric($currWord)){
$numberArray[] = $currWord;
}
$currWord = "";
}
}
return $numberArray;
}