i have following array:
array( [0] => array ( [user] => name [pwd] => jk ) [1] => array ( [user] => name [pwd] => ew [city]=> pune ) )
i trying count second index elements
[1] => array ( [user] => name [pwd] => ew [city]=> pune )
it must show count=2/3(if starts 1)
if i'm not wrong need this.
$ararr = array(array ( 'user' => 'name', 'pwd' => 'jk' ), array ( 'user' => 'name', 'pwd' => 'ew', 'city'=> 'pune' ) ); $count = ''; foreach($ararr $key => $value){ $count .= count($value).'/'; } echo substr($count,0,-1); // 2/3
and using array_map
function
$count = array_map(function ($t){ return $result = 'count '.count($t);},$ararr); print_r($count); //array ( [0] => count 2 [1] => count 3 )
Comments
Post a Comment