问题描述
我想知道如果任何人有一个递归解决方案到一个数组转换为字符串。
I'm wondering if anyone has a recursive solution to converting an array to a string.
这就是我的意思是:
阵列的$ args
具有以下内容:
Array
(
[0] => $hello
[1] => 411px
[Jeeves] => Array
(
[compiling] => 1
)
)
在调用后结果 arr_to_string($参数)
:
array($hello,"411px", "Jeeves" => array("compiling" => 1));
请注意:
它承认前面的$符号,因此不加引号。它同样的数字。
Note:It recognizes the $ sign in front and therefore does not add quotes. It does the same for numbers.
任何人有任何解决方案,也可以点我在正确的方向?
Anyone have any solution or can point me in the right direction?
谢谢!
马特·穆勒
Thanks!Matt Mueller
推荐答案
看起来你是在
- - 输出或返回一个字符串可解析重新变 的presentation
var_export
— Outputs or returns a parsable string representation of a variable
这不会给你打招呼$但是,因为$你好不能在数组中。它总是在变的仅仅是价值,而不是变量名。如果你想'$你好',把它放入单引号其插入到阵列,例如,当插入它作为一个字符串,而不是作为一个变量。
That won't give you $hello though, because $hello cannot be in an array. It's always just the value of the variable, not the variable name. If you want '$hello', put it into single quotes when inserting it to the array, e.g. insert it as a string, not as a variable.
这篇关于PHP数组为String相当于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!