Reply to Re: [PHP] Perl style

Your name:

Reply:


Posted by Sψren Schimkat on 10/20/25 11:30

Quoting rouvas <rouvas@di.uoa.gr>:

> Simpler(?) approach:
>
> $element5 = current(array_splice(split(',',$csvstring),5,1));
>
> This is fun!


Indeed... and this looks just fine. A great solution. Thanks. :-)


-SΓΈren


>
> -Stathis
>
> On Wednesday 26 October 2005 17:08, Jochem Maas wrote:
> > SΓΈren Schimkat wrote:
> > > Hi guys
> > >
> > > I would like to convert this ..
> > >
> > >
> > > $tmparray = split(',', $csvstring);
> >
> > don't use split() here - there is no need for regexp.
> > use explode() instead.
> >
> > > $element5 = $tmparray[5];
> > >
> > >
> > > . to something like this:
> > >
> > >
> > > $element5 = (split(',', $csvstring))[5];
> >
> > $csvstring = "1,2,3,4,5,6";
> > echo "route "; // humor me
> > echo $element5 = current(array_reverse(array_slice(explode(",",
> > $csvstring), 0, 6))); echo $element5 = end(array_slice(explode(",",
> > $csvstring), 0, 6));
> >
> > not as short as perl - unfortunately there is no valid
> > syntax that allows dereferenced access to array elements (AFAIK).
> >
> > > . but I just can't find the correct syntax. It is Perl style - i know,
> > > but I just love this syntax. :-)
> > >
> > > Does anyonw know the correct syntax?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
mvh SΓΈren Schimkat
www.schimkat.dk

---------------------------------------
www.dyrenes-venner.dk/densorteliste.asp

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация