Search code examples
phpwordpressloopswoocommercevendor

array_count_values i want to echo one specific key value


Im busy with a webshop and i want to echo how many orders this day has needs to delivert

I have a loop where i got the following code in:

$winkels[] = $vendor->id;

Thats good i got as i did the following code:

echo '<pre>'.print_r(array_count_values($winkels),true).'</pre>';

Than i get as result:

Array
(
   [63] => 1
   [45] => 1
   [85] => 1
   [59] => 1
)

The results are good, but how can i echo the value of id: 63 ?

Please can somebody help me out?


Solution

  • For single one:-

    $data = array_count_values($winkels); 
    echo $data[63];
    

    For all:-

    $data = array_count_values($winkels); 
    foreach($data as $key=>$val){
      echo $key.'=>'.$val;
    }