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.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  19.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  20.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  21.  * @link       http://dwoo.org/
  22.  * @version    1.0.0
  23.  * @date       2008-10-23
  24.  * @package    Dwoo
  25.  */
  26. function Dwoo_Plugin_array_compile(Dwoo_Compiler $compilerarray $rest=array())
  27. {
  28.     $out array();
  29.     foreach ($rest as $k=>$v{
  30.         if (is_numeric($k)) {
  31.             $out[$k.'=>'.$v;
  32.         else {
  33.             $out['"'.$k.'"=>'.$v;
  34.         }
  35.     }
  36.  
  37.     return 'array('.implode(', '$out).')';
  38. }

Documentation generated on Sat, 18 Jul 2009 21:05:06 +0200 by phpDocumentor 1.4.0