note 89759 added to functions.arguments

From: Date: Sat, 21 Mar 2009 22:34:38 +0000
Subject: note 89759 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-152270@lists.php.net to get a copy of this message
I like to pass an associative array as an argument. This is reminiscent of a Perl technique and can be tested with is_array. For example: <?php function div( $opt ) { $class = ''; $text = ''; if( is_array( $opt ) ) { foreach( $opt as $k => $v ) { switch( $k ) { case 'class': $class = "class = '$v'"; break; case 'text': $text = $v; break; } } } else { $text = $opt; } return "<div $class>$text</div>"; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 89.241.179.11 ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- https://master.php.net/note/edit/89759 Del: integrated -- https://master.php.net/note/delete/89759/integrated Del: useless -- https://master.php.net/note/delete/89759/useless Del: bad code -- https://master.php.net/note/delete/89759/bad+code Del: spam -- https://master.php.net/note/delete/89759/spam Del: non-english -- https://master.php.net/note/delete/89759/non-english Del: in docs -- https://master.php.net/note/delete/89759/in+docs Del: other reasons-- https://master.php.net/note/delete/89759 Reject -- https://master.php.net/note/reject/89759 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152270) next »