如果为null,则不会使用array_count_values发出警告

时间:2015-02-23 20:52:30

标签: php cakephp

在一个cakephp模型中,我像这样写了直接反击

        // array_layers_count
        $array_layers = array($val['Zombiesindexstats']['layer1'], etc... );
        $array_layers_count = array_count_values($array_layers);
        if ($array_layers_count['yes']) {
            $results[$key]['Zombiesindexstats']['layers_count'] = $array_layers_count['yes'];
        } else {
            $results[$key]['Zombiesindexstats']['layers_count'] = 0;
        }

如果没有'yes'索引,我总是在日志中发出警告'Undefined index:yes in ..'。怎么让它安静?

0 个答案:

没有答案
相关问题