Re: Use array returned by function directly?

From: Date: Mon, 29 Jan 2007 23:28:21 +0000
Subject: Re: Use array returned by function directly?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247967@lists.php.net to get a copy of this message
On Mon, January 29, 2007 7:03 am, ivailo91@gmail.com 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?

« previous php.general (#247967) next »