Print only numerics in string PHP?
i have a variable like this
$var=”am2c3″;
i want to print only numberics (2 and 3)
is there any function???
i am not aware if there is such function but you can however:
$var = "am2c3";
$chars = preg_split('//', $var, 0, PREG_SPLIT_NO_EMPTY);
foreach($chars as $val)
{
if(is_numeric($val))
{
print "".$val."
“;
}
}
?>
here you go fresh from my textWrangler….
powered by yahoo answers
[affmage source="amazon" results="5"]php is numeric[/affmage]
