1

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?

2 Answers 2

2

Just access the property of the array

echo $results[0]['amount']

php docs on arrays

Sign up to request clarification or add additional context in comments.

Comments

0

get a single item:

$query = $views->findById($id);
//or
$query = $views->get($id);

echo $query->amount;

or if you want to get em all

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

foreach ($query as $view) {
    echo $view->amount;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.