You are here: Re: [PHP] Quick Poll: PHP 4 / 5 « PHP « IT news, forums, messages
Re: [PHP] Quick Poll: PHP 4 / 5

Posted by "leaf" on 09/17/05 07:02

----- Original Message -----
From: "Jasper Bryant-Greene" <jasper@bryant-greene.name>
To: <php-general@lists.php.net>
Sent: Friday, September 16, 2005 4:45 PM
Subject: Re: [PHP] Quick Poll: PHP 4 / 5


> Stephen Leaf wrote:
>> So yes a bug. But for those that want to be able to grab only what we
>> need. in my case array_pop's returned element. I don't wanna be hassled
>> with the "are you sure you wanted to ignore part of what we did?"
>> It's almost like every program asking "are you sure you wanted to close
>> me?" everytime I get asked that I always think... "I did just click the
>> X.. so.... Yah......."
>
> But why use array_pop() to get the last element, when you know it's
> intended to shorten its passed array as well?
>
> I mean, sure, it might take a few more lines of code to do it properly,
> but it has the advantage that whoever has to look at the code next might
> actually understand what's going on in your head.
>
> $array = explode( ',', $some_string );
> $last_element_pos = count( $array ) - 1;
> $last_element = $array[$last_element_pos];
>
> [ sure, you could put the count( $array ) - 1 as the array subscript but I
> was just extending it out for illustration... it's probably easier to
> understand later on anyway. ]

Actually I choose array_pop for 2 reasons.
I like short code. I don't want to read thousands of lines just to get an
idea. I tend to think in very compact code. if you find that ugly and
unreadable. that's your preference. I find extended coding very ugly, mostly
because I'm a slow reader, and that is my preference
I got use to working with pop and shift while I was doing perl work. so to
me pop'ing an array makes perfect sense.

>
> --
> Jasper Bryant-Greene
> Freelance web developer
> http://jasper.bryant-greene.name/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this 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

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