I should check my version then... =O)

lux

Christian Reiniger wrote:

> On Monday 05 February 2001 00:51, Lux wrote:
> 
> 
>>> But the feature is useless :)
> 
>> 
> 
>>     function a ($hash, $text = "") {
> 
>>        $attr_text = "";
> 
>>        while (list ($k, $v) = each ($hash)) {
> 
>>           $attr_text .= " $k=\"$v\"";
> 
>>        }
> 
>>        return "<a$attr_text>$text</a>";
> 
>>     }
> 
> 
> 
>>     // what also doesn't work
> 
>>     // echo a (array("href" => "http://www.google.com/", "target" =>
>> "_blank"), "Visit Google!");
> 
> 
> 
> Works fine for me, sorry (php 4.0.4)
> 
> 
> 
> 
> 
> 
>>     // another example
> 
>> 
> 
>>     echo a ($attrs = array ("href" => "http://www.google.com/"),
> 
>>          img ($attrs = array (
> 
>>              "src" =>
>> "http://www.google.com/images/title_homepage4.gif", "alt" => "Visit
> 
>> Google!",
> 
>>              "border" => "0")
> 
>>          )
> 
>>     );
> 
> 
> 
> works, rewritten to 
> 
> echo a (array ("href" => "http://www.google.com/"),
> 
>       img (array (
> 
>                   "src" => "http://www.google.com/images/title_homepage4.gif",
> 
>                   "alt" => "Visit Google!",
> 
>                   "border" => "0")
> 
>           )
> 
>        );
> 
> 
> 
> 
> 
> 
>>     /* now ideally, this could be written much more cleanly, perhaps...
> 
>> 
> 
>>     echo a(['href' => [http://www.google.com/'],
> 
>>          img(['src' =>
>> 'http://www.google.com/images/title_homepage4.gif', 'alt' => 'Visit
> 
>> Google!', 'border' => '0'])
> 
>>     );
> 
>> 
> 
>>     */
> 
> 
> 
> 
> So it basically boils down to "array (a => b)" versus "[a => b]"
> 
> And I personally feel the array () notation is at least as nice as the [] 
> 
> one. Well, it's a matter of taste. But it certainly isn't harder to read, 
> 
> not detrimental on cleanness and elegance of the code.


-- 

John Luxford
Simian Systems

w: www.simian.ca
e: [EMAIL PROTECTED]
p: 204.946.5955

--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to