Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
mohammed abdi abdulahi warsame4,926 Points
couldent we just sett $arr as avriabel instead of $names?
in the code it says that=> function hello($arr),, and then when he is echoing he is using $name!!! couldent he just mentioned $arr DIRECTLY!!! Hope that my question is understand thanks alot
Kevin Korte28,147 Points
He he can't, it's the way foreach loops work. Foreach loops take an argument, in this case an array of names in
$arr and one by one, loads each individual name into a temporary variable that is only available inside of the foreach loop.
This explains it in more detail: http://php.net/manual/en/control-structures.foreach.php