[0] => stdClass Object
(
[fruit] => apple
[COUNT(form_value)] => 8
)
[1] => stdClass Object
(
[fruit] => apple
[COUNT(form_value)] => 5
)
Asked
Active
Viewed 44 times
0
CBroe
- 86,812
- 12
- 88
- 140
pmunankarmi
- 13
- 2
-
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
-
1Also 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 Answers
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
- 138
- 1
- 2
- 10