[ create a new paste ] login | about

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

PHP, pasted on Jul 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

    $test = "['n']['l']";

    echo "I've got a string with the array index ".$test. "\n";

    $person = array("n"=>array('l'=>'SMITH'));

    echo 'the array, $person, is this: '."\n";
    print_r($person);

    echo "What I want is ".$person['n']['l']. "\n";

eval("echo \$person$test;");


Output:
1
2
3
4
5
6
7
8
9
10
11
12
I've got a string with the array index ['n']['l']
the array, $person, is this: 
Array
(
    [n] => Array
        (
            [l] => SMITH
        )

)
What I want is SMITH
SMITH


Create a new paste based on this one


Comments: