Is there a way to encode variables as strings that can be evaluated as php code? In particular, I'm interested in associative arrays. (Scalar values and indexed arrays are encoded as valid php code by json_encode
. I don't need to encode objects and resources).
$Array = ['1', 2, 'key' => 'value'];
php_encode($Array); // => "[0 => '1', 1 => 2, 'key' => 'value']" or similar