suppose i have a multidimensional array like something like this:
<?php
$array = array("test1" => array("test2" => array("test3" => 1)), ... foo1 = array("foo2" => 2));
?>
i want to access an array element by passing a string like "test1.test2.test3"
to a function which in turn calls the array element. I could use eval()
by replacing the string with []
(calling $array["test2]["test3"]
...) but i wonder if there is a different more solid approach in calling a array element without traversing through all of its depth or use eval()
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…