user3704648 user3704648 - 3 months ago 19
PHP Question

How to retrieve a specific value from an array with keys and values in cakephp3

I am trying to access a specific value in the array that is formed after my query.

$query = $views->find('all');
$results = $query->all();
$data = $results->toArray();
$results = $query->toArray();

echo $results[0];

the echo shows {'id':1, 'date':2016-07-27,'amount':30}

I just want to get the 30 from amount. How would I go about doing that?



Just access the property of the array

echo $results[0]['amount']

php docs on arrays