This is my var_dump result in WordPress but when I want to echo “COUNT(*)” this showed error reports.
Parse error: syntax error, unexpected ‘*’ in

But “package” is showed well. How can I echo each “COUNT(*)

My sql is:

$aaaaa = $wpdb->get_results( "SELECT package, COUNT(*) FROM $table_name GROUP BY package");

var_dump Result:

 array (size=5)
      0 => 
        object(stdClass)[592]
          public 'package' => string 'package 1' (length=9)
          public 'COUNT(*)' => string '1' (length=1)
      1 => 
        object(stdClass)[593]
          public 'package' => string 'package 3' (length=9)
          public 'COUNT(*)' => string '3' (length=1)
      2 => 
        object(stdClass)[594]
          public 'package' => string 'Package 4' (length=9)
          public 'COUNT(*)' => string '2' (length=1)

Echo:

    echo  $aaaaa[2]->package;
    echo  $aaaaa[2]->COUNT(*);

Read more here: COUNT(*) is no echo in WordPress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: