JustTooCool Posted October 15, 2009 Share Posted October 15, 2009 I hope I'm not annoying anyone or breaking the rules but I was wondering about this bit of code right here: " <?php $people = Array( Array('name' => 'Kalle', 'salt' => 856412), Array('name' => 'Pierre', 'salt' => 215863) ); for($i = 0; $i < sizeof($people); ++$i) { $people[$i]['salt'] = rand(000000, 999999); } ?> " Okay from what I can get from this $i will continue to increase and the code will execute until ..... this seems too random or me to realize the goal of this code. Quote Link to comment https://forums.phpfreaks.com/topic/177739-new-to-php-and-just-trying-to-understand-a-little-code/ Share on other sites More sharing options...
sKunKbad Posted October 15, 2009 Share Posted October 15, 2009 It looks like all it is doing is changing the value of the salt key Quote Link to comment https://forums.phpfreaks.com/topic/177739-new-to-php-and-just-trying-to-understand-a-little-code/#findComment-937175 Share on other sites More sharing options...
Prismatic Posted October 15, 2009 Share Posted October 15, 2009 <?php // Populate $people with two arrays, each containing two entries. // "name" and "salt" $people = Array ( Array('name' => 'Kalle', 'salt' => 856412), Array('name' => 'Pierre', 'salt' => 215863 ) ); // for($i = 0; $i < the size of $people, which is two; add one to i) for($i = 0; $i < sizeof($people); ++$i) { // Assign a new value for "salt" on this array item. $people[$i]['salt'] = rand(000000, 999999); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/177739-new-to-php-and-just-trying-to-understand-a-little-code/#findComment-937185 Share on other sites More sharing options...
JustTooCool Posted October 15, 2009 Author Share Posted October 15, 2009 That cleared things up thanks a lot guys. PHP is a lot of fun. I started off on HTML but it was good and simple but for some reason I thought something was missing. Now that I have moved on to PHP I realized that it was control that creates all the fun. Hope to talk to you guys soon. Quote Link to comment https://forums.phpfreaks.com/topic/177739-new-to-php-and-just-trying-to-understand-a-little-code/#findComment-937742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.