Home > Mobile >  How can I return the count value from below array
How can I return the count value from below array

Time:09-24

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

    [1] => stdClass Object
        (
            [fruit] => apple
            [COUNT(form_value)] => 5
        )

CodePudding user response:

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'];
}
  • Related