Returns the php array to the php source code.
1.
[Code][PHP] code
"111", "bbb" => '000000', "ccc '=> array (),) */function array_assoc_code ($ arr, $ tab) {$ code = str_repeat ("\ t", $ tab ). "array (\ n"; if ($ arr) {foreach ($ arr AS $ k => $ v) {if (is_int ($ v) {$ code. = str_repeat ("\ t", $ tab ). "'$ k' => $ v, \ n";} elseif (is_array ($ v) {$ code. = str_repeat ("\ t", $ tab ). "'$ k' => \ n ". array_code ($ v, $ tab + 2); // recursive call. to associate an array, use tab + 2} else {$ code. = str_repeat ("\ t", $ tab ). "'$ k' =>' $ V', \ n" ;}}$ co De. = str_repeat ("\ t", $ tab ). "), \ n"; // There is a comma return $ code;}/* print the array and print it into php code */function array_code ($ arr, $ tab = 0) {if (is_assoc_array ($ arr) {return array_assoc_code ($ arr, $ tab) ;}else {return array_index_code ($ arr, $ tab );}} // -------------------- array to code --------------------------- end // test example $ arrTEST = array ("aaa" => "111", "bbb" => array (1, 3, array ("wu" => 1, "jun" => 2, "jie" => array ("aaa" => "bbb", "ccc" => "ddd ",); // Var_dump ($ arrTEST); die; echo array_code ($ arrTEST);?>