Does PHP4 have anything similar to perl's anonymous hash or array( $var = { 
'some' => 'hash elements' } or $var = [ 'array', 'elements' ] )

The reason I ask is I am trying to find a way of passing a variable length 
list of named parameters to a function without having to use a specific order.
i.e.
function my_func is expecting any of the following optional parameters:
fname, lname, city, state, zip

I can do this with the following code:
<?php
function my_func ( $input ){ echo '<PRE>';print_r( $input );echo '</PRE>'; }
$my_array = array( 'fname' => 'joe', 'lname'=>'coder', 'zip'=>'12345');
my_func( $my_array );
$my_array = array( 'city' => 'Brooklyn', 'state'=>'NY');
my_func( $my_array );
?>

To make it a little cleaner I would prefer to do something like:
my_func( {
         'fname' => 'joe'
        , 'lname'=>'coder'
        , 'zip'=>'12345'
} );

an not pollute the code with one-time vars

Thanks,
Morgan


-- 
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