1. function array_build(&$output, &$array, $indent){
  2.     $output .= 'array(';
  3.     $i = 0;
  4.     foreach($array as $key => $val){
  5.         if(is_string($key)){
  6.             $output .= '\'' . $key . '\' => ';
  7.         }
  8.         if(is_array($val)){
  9.             array_build($output, $array[$key], $indent++);
  10.         }else{
  11.             // Is the value a string, if so quote it.
  12.             if(is_string($val)){
  13.                 // Are we on the last iteration.
  14.                 if($i !== count($array) - 1){
  15.                     // Nope, comma seperate.
  16.                     $output .= '\'' . $val . '\', ';
  17.                 }else{
  18.                     // Yep, no comma.
  19.                     $output .= '\'' . $val . '\'';
  20.                 }
  21.             }else{
  22.                 // Are we on the last iteration.
  23.                 if($i !== count($array) - 1){
  24.                     // Nope, comma seperate.
  25.                     $output .= $val . ', ';
  26.                 }else{
  27.                     // Yep, no comma.
  28.                     $output .= $val;
  29.                 }
  30.             }
  31.         }
  32.  
  33.         // Increment i, check if we are on the last iteration.
  34.         ++$i;
  35.     }
  36.     $output .= ')';
  37.  
  38.     // Place a comma after all parent level elements.
  39.     if($indent === 1){
  40.         $output .= ', ';
  41.     }
  42. }