programmers_39
programmers_39

Reputation: 89

how to access key pair value of query result in php

I am trying to get the value of currentPdfDownload and max_download_limit from my $result array variable

var_dump($result); output:-

 array(1) {
          [0]=>
          object(stdClass)#1529 (2) {
            ["currentPdfDownload"]=>
            string(2) "42"
            ["max_download_limit"]=>
            string(2) "20"
          }
        }

I try this:

echo $result['currentPdfDownload']." ".$result['max_download_limit'];       

But it does not give any result.

Please highlight what I am doing wrong?

Thanks in advance

Upvotes: 1

Views: 46

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72269

You need to do it like below:-

echo $result[0]->currentPdfDownload." ".$result[0]->max_download_limit; 

Note:- Your array have an index 0 and on that index it have an object array so you need to use [0] and -> to fetch it's indexes as property of an object

Upvotes: 2

Related Questions