Re: [PHP] operators as callbacks?

2008-11-29 Thread Nathan Nobbe
On Sat, Nov 29, 2008 at 2:42 PM, Joe <[EMAIL PROTECTED]> wrote:

> Is it possible to use a PHP operator as a callback?


not that im aware of, even if you use the operator overloading extension, im
not sure youll find that ability.

I can use the BC library's math functions instead:
>  array_map('bcadd', $array1, $array2)
> but that is an ugly hack that might break if the library is not available.


 i dont know how bad that is really, i guess it depends on the distribution
scope of the application.  if its in a controlled environment, id just say
install bcmath and forget it.

I can create an anonymous function:
>  array_map(create_function('$a, $b', 'return $a + $b;'), $array1, $array2)
> but that seems really unnecessarily verbose.


well, youll just have to wait for 5.3 and its new lambda notation, youll be
able to do this (something close anyway :)),

array_map(function($a, $b) { return $a + $b; }, $array1, $array2);

it doesnt look like much difference here, but create_function() gets a lot
worse w/ functions any less trivial than adding 2 numbers.

Is there any simple clean way to do it? Thanks,


i think youre beating your head against the wall for no good reason.  your
solutions are fine, just pick one and roll w/ it ;)

-nathan


Re: [PHP] operators

2005-12-28 Thread Ligaya Turmelle


$xml->Result[$i]  - a method call for object $xml
$key=>$value  - array notation

Henry Krinkle wrote:

 I have some experience with PHP, but not with these operators:

->
=> 


Can someone explain how they are working in this snippet from Yahoo's search API

foreach($xml->Result[$i] as $key=>$value) 


I don't see anything about them in the "Array Operators" documentation..

Thanks



-
Yahoo! for Good - Make a difference this year. 


--

life is a game... so have fun.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Operators

2002-01-10 Thread Johnson, Kirk



> If != is the opposite of ==
> What is the opposite of === ??

I believe that is !==

Kirk

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