Jump to content

Recommended Posts

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.

<?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);
}

?>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.