Convert a String to Variable

后端 未结 9 2149
臣服心动
臣服心动 2020-12-01 05:43

I\'ve got a multidimensional associative array which includes an elements like

$data[\"status\"]
$data[\"response\"][\"url\"]
$data[\"entry\"][\"0\"][\"text\         


        
9条回答
  •  一生所求
    2020-12-01 06:32

    PHP's variable variables will help you out here. You can use them by prefixing the variable with another dollar sign:

    $foo = "Hello, world!";
    $bar = "foo";
    echo $$bar; // outputs "Hello, world!"
    

提交回复
热议问题