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
Post a Comment