-1
[0] => stdClass Object
        (
            [fruit] => apple
            [COUNT(form_value)] => 8
        )

    [1] => stdClass Object
        (
            [fruit] => apple
            [COUNT(form_value)] => 5
        )
CBroe
  • 91,630
  • 14
  • 92
  • 150
  • 1
    Does this answer your question? [How to access object properties with names like integers or invalid property names?](https://stackoverflow.com/questions/10333016/how-to-access-object-properties-with-names-like-integers-or-invalid-property-nam) – CBroe Sep 24 '21 at 09:10
  • 2
    Also you can add __alias__ to `COUNT(form_value)` in your sql query – u_mulder Sep 24 '21 at 09:27
  • To explain @u_mulders comment. If you do `SELECT COUNT(form_value) FROM table` the key of the result will be _COUNT(form_value)_. If you do `SELECT COUNT(form_value) AS form_value FROM table` the key will be _form_value_ – Michel Sep 24 '21 at 09:30
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 01 '21 at 18:39

1 Answers1

0

First, you can rename the COUNT(form_value) in your SQL Query. For example use:

SELECT COUNT(form_value) AS form_value_count FROM %your_table_name%

To get all counts from you array, you can use (if you change your SQL-query):

foreach(%your_array_variable% AS $d){
    echo $d['form_value_count'];
}
CooleKikker2
  • 228
  • 1
  • 3
  • 11