我如何判断一个变量是否是数字,以及它是否';s偶数


How can I tell if a variable is numeric and if it's even?

我需要我的脚本来告诉我一个变量是否是数字,如果是,它是否是偶数。到目前为止我的代码:

        $Numbers = array("1", 2, "three", 4, 5, "six");
        foreach ($Numbers as $Value) {
            if (is_numeric($Value)) {
                if ($Value % 2 == 0) {
                    echo "$Value is numeric, and even";
                } else {
                    echo "$Value is numeric, but not even";
                }
            } else {
                echo "$Value is not numeric";
            }

我的浏览器显示一个空白页。

如有任何帮助,我们将不胜感激。

语法错误。关闭foreach循环

 $Numbers = array("1", 2, "three", 4, 5, "six");
        foreach ($Numbers as $Value)
        {
            if (is_numeric($Value))
            {
                if ($Value % 2 == 0)
                {
                    echo "$Value is numeric, and even";
                }
                else
                {
                    echo "$Value is numeric, but not even";
                }
            }
            else
            {
                echo "$Value is not numeric";
            }
}