Re: Is this a missing feature?

From: Date: Mon, 05 Feb 2001 00:14:36 +0000
Subject: Re: Is this a missing feature?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-38162@lists.php.net to get a copy of this message
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. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka", but "That's funny..." - Isaac Asimov

« previous php.general (#38162) next »