Syntax ::: does explode('-', $string)[2] ::: have a twin brother?

From: Date: Tue, 19 Dec 2000 03:26:19 +0000
Subject: Syntax ::: does explode('-', $string)[2] ::: have a twin brother?
Groups: php.general 
Request: Send a blank email to php-general+get-30981@lists.php.net to get a copy of this message
Did I see it somewhere or I dreamed it off my tired mind? I was wondering if there is a way to say this: $to = explode('-', $string); $to = $to[2]; somehow like this: $to = explode('-', $string)[2]; Here's my test page: $string = '2000-05-12'; $to = explode('-', $string); $to = $to[2]; echo " $string ::: $to "; unset ($to); echo '<P>'; $to = explode('-', $string)[2]; echo " $string ::: $to "; And, of course, it doesn't work ... I am asking it because I though that I've seen it somewhere before, I basically don't need an array at all, yet I would like to keep the variable called $to. I am sure that the key [2] is what I need. I could even use substring() but my curiosity doesn't let me to. I want to know if there's a way to assign an array key to a function which that produce an array. Just syntax staff.. Cheers. Maxim Maletsky. Maxim Maletsky - maxim@j-door.com <mailto:maxim@j-door.com> Webmaster, J-Door.com / J@pan Inc. LINC Media, Inc. TEL: 03-3499-2175 x 1271 FAX: 03-3499-3109 http://www.j-door.com <http://www.j-door.com/> http://www.japaninc.net <http://www.japaninc.net/> http://www.lincmedia.co.jp <http://www.lincmedia.co.jp/>

« previous php.general (#30981) next »