Codice PHP:
<?php
function var_explort()
{
$args = func_get_args();
$print = "$args[0] = array();\n";
$i = 0;
foreach($args[1] as $k => $v)
{
if (is_array($k))
{
foreach($k as $k2 => $v2)
if (is_numeric($v2))
$print .= "$args[0]['$k'][$i] = $v2;\n";
else
$print .= "$args[0]['$k'][$i] =
'$v2';\n";
}
else
if (is_null($v))
$print .= "$args[0]['$k'] = NULL;\n";
else
if (is_numeric($v))
$print .= "$args[0]['$k'] = $v;\n";
else
$print .= "$args[0]['$k'] = $v;\n";
$i++;
}
return $print;
}
$c=var_explort('$nome_array', array(1=>'a',2,3));
print $c;
?>
non mi controlla i tipi ... al posto di is_array()/is_null()/is_numeric()/etc... potrei metterci quello che voglio, ma ttanto if resituisce sempre vero...