php - function inside the declaration of a loop? -


take example:

foreach(explode(' ','word1 word2 word3') $v)  echo $v; 

from know php doens't execute every time explode function, executed first time.

is true? , true user-defined functions?

is code better or it's equal?

$genericvar = explode(' ','word1 word2 word3'); foreach($genericvar $v)  echo $v; 

thanks

when using foreach, 2 pieces of code equivalent. function explode called once.

however, not how works loops, example :

for($i = 0; $i < count($array); ++$i) {} 

in example, count function called @ each iteration.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -