home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / array2php.inc < prev    next >
Encoding:
Text File  |  2003-03-16  |  1.1 KB  |  41 lines

  1. <?php
  2. /////////////////////////////////////////////////////////
  3. //    
  4. //    include/array2php.inc
  5. //
  6. //    (C)Copyright 2000-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
  7. //
  8. //    This file is part of IlohaMail. IlohaMail is free software released 
  9. //    under the GPL license.  See enclosed file COPYING for details, or 
  10. //    see http://www.fsf.org/copyleft/gpl.html
  11. //
  12. /////////////////////////////////////////////////////////
  13.  
  14. /********************************************************
  15.     FUNCTION: Array2PHP
  16.     PURPOSE:
  17.         Given an array, generate equivalent PHP code that
  18.         will return the same array.
  19.     PRE-CONDITION:
  20.         $a - Array
  21.         $varname - Variable name to use in generated code
  22.     POST-CONDITION:
  23.         string - PHP code equivalent to array.  Does not
  24.                 include '<?php' tags.
  25. ********************************************************/
  26.  
  27. function Array2PHP($a,$varname){
  28.     $str.="\$".$varname."=array(\n";
  29.     $i=0;
  30.     reset($a);
  31.      while (list($key, $value) = each ($a)) {
  32.          $str.=($i>0?",":"")."\"".$key."\"=>\"".$value."\"\n";
  33.          $i++;
  34.      }
  35.     $str.=");\n";
  36.     
  37.     return $str;
  38. }
  39.  
  40. ?>
  41.