<?php
$str = '+0123qq';
$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
print_r($chars);
echo "<br>";
$num=0;
$letters=0;
foreach($chars as $elements){
if (is_numeric($elements)) {
$num+=1;
}
else{
$letters+=1;
}
}
echo " array got $num numbers";
echo "<br>";
echo " array got $letters letters";
?>
No hay comentarios:
Publicar un comentario