You are here: Re: Why not use a foreach loop instead of having a function called array_walk? « PHP Programming Language « IT news, forums, messages
Re: Why not use a foreach loop instead of having a function called array_walk?

Posted by thib΄ on 01/08/08 02:12

adam.timberlake@gmail.com wrote:
> I was reading this article yesterday:
> http://www.talkphp.com/advanced-php-programming/1886-how-would-i-apply-htmlentities-every-array-item.html
>
> I am wondering.. okay.. we can use array_walk but doesn't that just
> loop through the items anyway ?? So why not just use the foreach loop
> instead... is it a shorthand trick or is there any deeper reasoning
> behind it... Thats my question!
>
> I do have another question and that is if it is a shorthand version,
> having a foreach loop isn't much more in terms of the letters you type
> and so why have the PHP developers put it in there ??
>
> It's puzzling me. Thank you in advance.

Well, array_walk() lets you use a callback function to treat your data,
which is a totally different approach to the structure of your script;
whereas yes, it's always possible (I guess) to do things with 'classic'
loops.

I don't pretend, it remains a good question; but IMO there isn't any
deeper reasoning behind it.

Anyway, concerning your doubts about what to use and when, I recently
found some really good reading here:
http://www.blueshoes.org/phpBench.php

I don't know if it answers your question correctly, but you should take
a look, it's worth it ;).

-thibΒ΄

 

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

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