SHARE
TWEET

James Hartig

a guest Dec 2nd, 2010 326 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function arrayToText(array $array) {
  2.     $return = "array(\n";
  3.     $arrayParse = function($array, $level=1) use (&$arrayParse, &$return) {
  4.         foreach ($array as $key => $val) {
  5.             for ($i=0;$i<$level;$i++){$return .= "\t";}
  6.             if (is_array($val)) {
  7.                 $return .=  '['.$key.'] => array('."\n";
  8.                 $arrayParse($val, $level+1);
  9.                 for ($i=0;$i<$level;$i++){$return .= "\t";}
  10.                 $return .= "),";
  11.             } else {
  12.                 $return .= '['.$key.'] => "'.$val.'",';
  13.             }
  14.             $return .= "\n";
  15.         }
  16.     };
  17.     $arrayParse($array);
  18.     $return .= ");";
  19.     return $return;
  20. }
RAW Paste Data
Top