Home >Backend Development >PHP Tutorial >数组统计问题

数组统计问题

WBOY
WBOYOriginal
2016-06-23 13:21:46963browse

 请问怎么实现判断有多少个访问成功200 有多少个访问失败404


回复讨论(解决方案)

$a = array(  array('mode' => '  200 47 '),  array('mode' => '  200 47 '),  array('mode' => '  404 47 '),  array('mode' => '  404 47 '),  array('mode' => '  200 47 '),);foreach($a as $t) {  @$res[intval($t['mode'])]++;}print_r($res);
Array(    [200] => 3    [404] => 2)

$arr = array(array('mode'=>'404 47'),array('mode'=>'200 47'),array('mode'=>'404 47'));$i = 0;$x = 0;$y = 0;while($i<count($arr)){    $a = explode(' ',$arr[$i]['mode']);    if($a[0]=='404'){        $x = $x + 1 ;    }elseif($a[0]=='200'){        $y = $y + 1;    }    $i++;}echo '404:'.$x,',200:'.$y;

我初学者,

$a = array(  array('mode' => '  200 47 '),  array('mode' => '  200 47 '),  array('mode' => '  404 47 '),  array('mode' => '  404 47 '),  array('mode' => '  200 47 '),);foreach($a as $t) {  @$res[intval($t['mode'])]++;}print_r($res);
Array(    [200] => 3    [404] => 2)

谢谢大神!!
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