If you want a copy of it then
$a = $arrayX;
However if you have to convert it to some string format then the better way of doing it would be this
$dump = var_export($a,true);
eval('$b = ' . $dump . ';');
Or better yet
$s = serialize($a);
$c = unserialize($s);
If that does not do it then here is how to parse the vardump format in question
function parseValue($value) {
return substr(preg_replace('/\s*[a-z]+\([0-9]+\)\s+"(.*)/','\\1',$value),0,-2);
}
function parseIndex($index) {
return preg_replace('/[^[]*\[([0-9]+)\].*/','\\1',$index);
}
function parseVardump($dump) {
$lines = explode("
",$dump);
foreach ($lines as $line) {
switch (true) {
case preg_match('/array\([0-9]+\) {/',$line) :
break;
case preg_match('/\[[0-9]+\]=>/',$line) :
// end previous value
if (isset($index)) {
$ar[$index] = parseValue($value);
}
$index = parseIndex($line);
$value = '';
break;
case preg_match('/}$/',$line) :
if (isset($index)) {
$ar[$index] = parseValue($value);
}
break;
default:
$value .= $line . "
";
break;
}
}
return $ar;
}
$a = array("AAA
", 'BBB' , 'CCC','DDD', 'EEE', 'FFF');
ob_start();
var_dump($a);
$dump = ob_get_contents();
ob_end_clean();
$ar = parseVardump($dump);