Maybe this? A bit verbose, but functional.

-Steve

<?php

function foo($p)
{
   if (empty($p['fred'])){
     $p['fred'] = 'hello';
   }
   if (empty($p['banana'])){
     $p['banana'] = 'world';
   }
   echo  $p['fred'] . $p['banana'];
}

foo(array('fred' => 'hello', 'banana' => 'world'));

?>

On Tuesday, September 25, 2001, at 06:25  AM, Andrey Hristov wrote:

> Yeap, I know that. I thought about this bit of hack but this breaks the 
> conception on giving parameters. Also this trick cannot
> solve the problem with default parameters. If I have function with 5 
> params and all of them have default values and I want to pass
> value only to the second parameter what I have to do?
>
> Andrey Hristov
> IcyGEN Corporation
> http://www.icygen.com
> BALANCED SOLUTIONS
>
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "Andrey Hristov" <[EMAIL PROTECTED]>
> Sent: Tuesday, September 25, 2001 1:14 PM
> Subject: Re: [PHP] Feature?
>
>
>> On Tue, 25 Sep 2001 11:36:25 +0300, you wrote:
>>
>>> In the case when I've few parameters I've to remember their order, so 
>>> why not
>>> $bar=foo('par2'=>10);
>>> I want to pass value to only one or more but not to all params.
>>> Also this will make the code clearer I think.
>>> Comments are welcome!
>>
>> <?php
>>
>> function foo($p)
>> {
>>   echo  $p['fred'] . $p['banana'];
>> }
>>
>> foo(array('fred' => 'hello', 'banana' => 'world'));
>>
>> ?>
>>
>
>
> --
> 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]
>

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