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

From: Date: Tue, 19 Dec 2000 18:13:45 +0000
Subject: Re: Syntax ::: does explode('-', $string)[2] ::: have a
References: 1  Groups: php.general php.general 
Request: Send a blank email to php-general+get-31231@lists.php.net to get a copy of this message
I believe $to = strrchr( '2000-05-12' , '-' ) ; is what you're looking for. I know it ain't "scary", but does the job quite efficiently. :) At 04:26 19.12. 2000, Maxim Maletsky wrote the following: -------------------------------------------------------------- >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/> > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#31231) next »