hi all
i have a string like "123 abc 45".
i am using the below code to extract numeric from string. The result i get for numeric value is "12345".
How can i get the result as "123" and "45" as separate two keywords.
<?php
$string = "123 abc 45";
$chars = '';
$nums = '';
for ($index=0;$index<strlen($string);$index++) {
if(isNumber($string[$index]))
$nums .= $string[$index];
else
$chars .= $string[$index];
}
echo "Chars: $chars<br>Nums: $nums";
function isNumber($c) {
return preg_match('/[0-9]/', $c);
}
?>
vineet