[ create a new paste ] login | about

Link: http://codepad.org/6JJt6JXs    [ raw code | output | fork ]

PHP, pasted on Jun 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?
$arr = array(
  'testRootKey' => array(
    'testKey' => array(
     'prop1' => 'works'
    )
  )
);

$rootKey = 'testRootKey';
$testKey = 'testKey';
$propKey = 'prop1';
$nonExistingPropkey = 'prop2';

echo $arr[ $rootKey ][ $testKey ][ $propKey ]; // -> works
echo "\n";
$arr[ $rootKey ][ $testKey ][ $nonExistingPropkey ] = 'new prop';
echo $arr[ $rootKey ][ $testKey ][ $nonExistingPropkey ]; // -> new prop


Output:
1
2
works
new prop


Create a new paste based on this one


Comments: