I have an array problem and have been working on this for months.
$results = $wpdb->get_results('SELECT COUNT(*) AS $total FROM
wp_realty_listingsdb');
print "<pre>";
print_r($results);
print "</pre>";
Array
(
[0] => stdClass Object
(
[$total] => 25
)
)
$results = $wpdb->get_results('SELECT COUNT(*) FROM
wp_realty_listingsdb');
print "<pre>";
print_r($results);
print "</pre>";
Array
(
[0] => stdClass Object
(
[COUNT(*)] => 25
)
)
$cars=array("Volvo");
print "<pre>";
print_r($cars);
print "</pre>";
echo $cars[0];
Array
(
[0] => Volvo
)
Volvo
So as it goes I have no problem using the echo to get the cars variable but no matter what I do I cannot get the variables from the above arrays... I have tried all of the following to no avail.
echo $results['total']
echo $results['0']
echo [0][total]
echo array[0][total]
echo $results['count']
You can see the image of the arrays here as to how they look:
Really appreciate any help what so ever.
You can access the 1st one like the following way
$results[0]->{'$total'}
Same for the second one
$results[0]->{'COUNT(*)'}