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 1 : function Dwoo_Plugin_array_compile(Dwoo_Compiler $compiler, array $rest=array())
27 : {
28 11 : $out = array();
29 11 : foreach ($rest as $k=>$v) {
30 10 : if (is_numeric($k)) {
31 9 : $out[] = $k.'=>'.$v;
32 9 : } else {
33 4 : $out[] = '"'.$k.'"=>'.$v;
34 : }
35 11 : }
36 :
37 11 : return 'array('.implode(', ', $out).')';
38 : }
|