Source for file helper.array.php

Documentation is available at helper.array.php

  1. <?php
  2.  
  3. /**
  4.  * Builds an array with all the provided variables, use named parameters to make an associative array
  5.  * <pre>
  6.  *  * rest : any number of variables, strings or anything that you want to store in the array
  7.  * </pre>
  8.  * Example :
  9.  *
  10.  * <code>
  11.  * {array(a, b, c)} results in array(0=>'a', 1=>'b', 2=>'c')
  12.  * {array(a=foo, b=5, c=array(4,5))} results in array('a'=>'foo', 'b'=>5, 'c'=>array(0=>4, 1=>5))
  13.  * </code>
  14.  *
  15.  * This software is provided 'as-is', without any express or implied warranty.
  16.  * In no event will the authors be held liable for any damages arising from the use of this software.
  17.  *
  18.  * This file is released under the LGPL
  19.  * "GNU Lesser General Public License"
  20.  * More information can be found here:
  21.  * {@link http://www.gnu.org/copyleft/lesser.html}
  22.  *
  23.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  24.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  25.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  26.  * @link       http://dwoo.org/
  27.  * @version    0.9.1
  28.  * @date       2008-05-30
  29.  * @package    Dwoo
  30.  */
  31. function Dwoo_Plugin_array_compile(Dwoo_Compiler $compilerarray $rest=array())
  32. {
  33.     $out array();
  34.     foreach ($rest as $k=>$v{
  35.         if (is_numeric($k)) {
  36.             $out[$k.'=>'.$v;
  37.         else {
  38.             $out['"'.$k.'"=>'.$v;
  39.         }
  40.     }
  41.  
  42.     return 'array('.implode(', '$out).')';
  43. }

Documentation generated on Sat, 28 Jun 2008 01:38:26 +0200 by phpDocumentor 1.4.0