php - How can I count the values in an array? -


i have attempted print values of array, cannot seem total count of array. i've tried count(), sizeof() , array_count_values neither of these functions seems job.

$query = db::getinstance()->query("select orderstatus customerorders");                   foreach ($query->results() $orderered) {     $result_array = array($orderered);  //print_r($result_array);    $orderdata = array_map(function ($object) { return $object->orderstatus; }, $result_array);    $test = json_decode(json_encode($result_array), true);      $orvalue = serialize($test);     $orvalue2 = unserialize($orvalue);     $ordervaluenew = call_user_func_array('array_merge', $orvalue2);     print_r($ordervaluenew);//debug     }//close foreach loop 

results of array after printing:

array ( [orderstatus] => 0 )  array ( [orderstatus] => 0 )  array ( [orderstatus] => 0 )  array ( [orderstatus] => 1 )  array ( [orderstatus] => 1 )  

after performing count() , sizeof:

11111  

after running array_count_values:

echo (array_count_values($ordervaluenew)); arrayarrayarrayarrayarray  

the count function work here:

$results = $query->results();  $num = count($values);  foreach($results $ordered) { // etc.  

Popular posts from this blog