首页 > 技术文章 > 判断一个数组里面的所有键所对应的值是否是为int型

xieqijiang 2020-05-25 14:57 原文

<?php
$tests = array(
"sdas"=>13
);
foreach ($tests as $element) {
if (is_numeric($element)) {
echo "'{$element}' is numeric", PHP_EOL;
} else {
echo "'{$element}' is NOT numeric", PHP_EOL;
}
}
?>
//http://www.nowamagic.net/librarys/veda/detail/2023

推荐阅读