Output an array as PHP eval-able code
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);
精彩评论