user3314370
user3314370

Reputation: 11

PHP - Obtain specific values within Mutidimensional Array

I have an array as follows:

[STATUS] => Array
   (
             [Information] = A
             [More Info ] = B
   )
[GPU0] => Array
   (
             [GPU] => 0
             [INFO] => 100
   )

Looking to use PHP to show [INFO] results. Right now I have something like this:

$array = print_r($result, true)."\n";
echo $array['GPU0']['GPU'];

My results are as follows:

Illegal string offset 'GPU0' in /var/www/somethinghere.php on line 117

Upvotes: 0

Views: 38

Answers (1)

Barmar
Barmar

Reputation: 780724

$result is an array, $array is a string that contains what print_r would have printed. You should do:

echo $result['GPU0']['GPU'];

DEMO

Upvotes: 2

Related Questions