I'm working on a program that takes a saved variable file and converts it to a string that is structured like a php array. My problem is I need to turn this string into an array in php. Hoping someone can help.
working example of recursive array: (simplified for easy readability)
[php]$test = array(blah => value, blah2 => value2, array1 => array(value1 => key1, blah4 => value4),blah3 => value3);
recursiveArray( $test);
function recursiveArray( $array) {
foreach ($array as $key => $value) {
if (is_array($valu e)) {
echo $key."<br>";
recursiveArray( $value);
} else {
echo $key." - ".$value."<br>" ;
}
}
}[/php]what I would like to send in is something like this, where the "array" is actually a string:
[php]$test = eval("array(bla h => value);");[/php]Am I missing something or is there another way to do this?
Thanks,
Dave
working example of recursive array: (simplified for easy readability)
[php]$test = array(blah => value, blah2 => value2, array1 => array(value1 => key1, blah4 => value4),blah3 => value3);
recursiveArray( $test);
function recursiveArray( $array) {
foreach ($array as $key => $value) {
if (is_array($valu e)) {
echo $key."<br>";
recursiveArray( $value);
} else {
echo $key." - ".$value."<br>" ;
}
}
}[/php]what I would like to send in is something like this, where the "array" is actually a string:
[php]$test = eval("array(bla h => value);");[/php]Am I missing something or is there another way to do this?
Thanks,
Dave
Comment