开发者

Output an array as PHP eval-able code

开发者 https://www.devze.com 2023-02-08 11:30 出处:网络
Basically I want some function like array_as_php which is essentially the inverse of eval: $array = array( \'1\' => \'b\', \'2\' => \'c\' );

Basically I want some function like array_as_php which is essentially the inverse of eval:

$array = array( '1' => 'b', '2' => 'c' );
echo array_as_php($array);

will print the following eval-able 开发者_开发问答string:

array( '1' => 'b', '2' => 'c' )


var_export() is what you are looking for.

$array = array ('1' => 'b', '2' => 'c' );
echo var_export($array, true);
0

精彩评论

暂无评论...
验证码 换一张
取 消