خرید بک لینک

Vote count: 0

This may be a basic question but I am struggling with a way to count values without doing multiple foreach loops. I have this array of objects (partial list included):

array(51) {
  [0]=>
  object(stdClass)#971 (4) {
    ["hole"]=>
    string(1) "2"
    ["club"]=>
    string(1) "6"
    ["shot_type"]=>
    string(1) "6"
    ["shot_loc"]=>
    string(1) "6"
  }
  [1]=>
  object(stdClass)#970 (4) {
    ["hole"]=>
    string(1) "2"
    ["club"]=>
    string(2) "16"
    ["shot_type"]=>
    string(1) "8"
    ["shot_loc"]=>
    string(1) "1"
  }
  [2]=>
  object(stdClass)#969 (4) {
    ["hole"]=>
    string(1) "2"
    ["club"]=>
    string(2) "19"
    ["shot_type"]=>
    string(1) "3"
    ["shot_loc"]=>
    string(1) "2"
  }
  [3]=>
  object(stdClass)#968 (4) {
    ["hole"]=>
    string(1) "1"
    ["club"]=>
    string(1) "1"
    ["shot_type"]=>
    string(1) "6"
    ["shot_loc"]=>
    string(1) "6"
  }
  [4]=>
  object(stdClass)#967 (4) {
    ["hole"]=>
    string(1) "1"
    ["club"]=>
    string(2) "15"
    ["shot_type"]=>
    string(1) "5"
    ["shot_loc"]=>
    string(1) "3"
  }

The number of objects in the list but each object will have the key=>values as shown. What I would like to retu is an array with count of each of the values of "hole". Something like this:

`array(18) {
  [1]=> 4
  [2]=> 5
  [3]=> 6`

and so on where the key is each of the values of "hole" and the new array value is the count.

I have attempted forms of count, count(get_object_vars($)), and others but all examples I find are counting the objects. Thanks in advance.

asked 39 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 27 فروردين 1395 ساعت: 8:27

صفحه بندی