Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i access such a php array

Tags:

arrays

php

i was trying to access this php array with no luck, i want to access the [icon] => icon.png

Array ( [total] => 2 
  [total_grouped] => 2 
  [notifys] => Array ( [0] => Array ( [notifytype_id] => 12 
           [grouped] => 930 
           [icon] => icon.png 
           [n_url] => wall_action.php?id=930 
           [desc] => 690706096 
           [text] => Array ( [0] => Sarah O'conner ) [total] => 1 )))
like image 806
clonex1 Avatar asked May 04 '26 09:05

clonex1


1 Answers

$arr['notifys'][0]['icon']

ETA: I'm not sure what your comment means, the following code:

$arr = array('total'=>2, 'total_grouped' => 2, 'notifys' => array(array(
'notifytype_id' => 12, 'icon' => 'icon.png')));
echo '<pre>';
print_r($arr);
echo '</pre>';
var_dump($arr['notifys'][0]['icon']);

outputs:

Array
(
    [total] => 2
    [total_grouped] => 2
    [notifys] => Array
        (
            [0] => Array
                (
                    [notifytype_id] => 12
                    [icon] => icon.png
                )

        )

)

string(8) "icon.png" 

Generally, code never outputs nothing. You should be developing with all errors and notifications on.

like image 190
SilentGhost Avatar answered May 06 '26 23:05

SilentGhost