Reply to Re: [PHP] Perl style

Your name:

Reply:


Posted by Jochem Maas on 10/26/05 17:08

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?
>
>

[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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация