Mat*_*att 5 php arrays recursion
我想知道是否有人有一个递归解决方案将数组转换为字符串.
这就是我的意思:
一个包含$args以下内容的数组:
Array
(
[0] => $hello
[1] => 411px
[Jeeves] => Array
(
[compiling] => 1
)
)
Run Code Online (Sandbox Code Playgroud)
调用后的结果arr_to_string($args):
array($hello,"411px", "Jeeves" => array("compiling" => 1));
Run Code Online (Sandbox Code Playgroud)
注意:它识别前面的$符号,因此不添加引号.它对数字也是一样的.
任何人有任何解决方案或可以指出我正确的方向?
谢谢!马特穆勒
Gor*_*don 16
看起来你在追求
var_export - 输出或返回变量的可解析字符串表示形式这不会给你$ hello,因为$ hello不能在数组中.它始终只是变量的值,而不是变量名称.如果你想要'$ hello',在将它插入数组时将其放入单引号中,例如将其作为字符串插入,而不是作为变量插入.