Re: Use array returned by function directly?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, January 29, 2007 7:03 am, ivailo91@xxxxxxxxx wrote:
> What's the best way to achieve something like this:
> explode($needle, $array)[3]
> It's too clumsy to use temporary array, and I suppose, quite slow. Is
> there any option, or I'll have to stick to temporary arrays?

Maybe some kind of preg_match or 3 strpos in a row...

If the array will be HUGE these might be faster, but you could also
just "hide" the temp array with something like:

function third($needle, $string){
  $temp = explode($needle, $string);
  return $temp[3];
}

There was discussion on PHP-Internals about allowing the syntax you
just typed above (though $array is really a $string, right?) but I
don't think it passed muster...

Go use C++ or something if you want to type things that complicated.
:-) :-) :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux