Home >php教程 >PHP源码 >输入N个数组,统计不同元素出现的次数

输入N个数组,统计不同元素出现的次数

PHP中文网
PHP中文网Original
2016-05-26 08:20:351356browse

跳至

meta[] = func_get_args();
    }

    public function show() {

        foreach ($this->meta[0] as $value) {
            foreach ($value as $subvalue) {
                if (!in_array($subvalue, $this->meger)) {
                    $this->meger[] = $subvalue;
                    $this->result["$subvalue"] = 1;
                } elseif (in_array($subvalue, $this->meger)) {
                    $this->result["$subvalue"] ++;
                }
            }
        }
        print_r($this->result);
    }

}

$arr1 = array('a', 'b', 'd');
$arr2 = array('d', 'de', 'ef');
$arr3 = array('a', 'ef', 'r', 'q');
$arr4 = array('b', 'de', 'q', 'z');
$arr5 = array('1', 'de', 'q', '3r');
$arr6 = array(1, 2, 'mn', '0y');
$arr7 = array(1, 'v2d', 'mn', '0y');
$s = new Statistics($arr1, $arr2, $arr3, $arr4, $arr5, $arr6, $arr7);
$s->show();
?>

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn