• 10Nov

    Hopefully you won’t crash into a car, but here in this tutorial you will learn about the foreach loop that we can use with my favorite variable: the array. This is very useful when objects in the array may not be in order, or they are not all identified by numbers(in some cases, there are no numbers).
    You need flash to play this tutorial.
    This tutorial goes over the following goals:
    Looping
    While X < ? Do this..
    For X starts as 0 to 10 do this
    foreach bucket in my closet fill it with water(not really)
    You can find this tutorial video on youtube here.

    Here are the sources used in this tutorial:
    tut011.php
    <?php
    //PHP Tutorial 011
    
    //while
    /*for($x = 0; $x < 4; $x+=1){
    	echo "taco 123-$x<br />";
    }*/
    
    $array = array();
    
    $array[] = array("socks",12);
    $array[] = array("toilet paper",20);
    
    $array[] = array("pudding", 0.02);
    $array[] = array("forks", 30);
    
    foreach($array as $itemy){
    	echo $itemy[0]." is $".$itemy[1]."<br />";
    
    }
    
    //echo "bricks.";
    
    /*$x = 0;
    while($x < 4){
    	echo "taco 123<br />";
    	$x+=1;
    }*/
    
    ?>

    Here are all the php functions used in this tutorial:

    Posted by Kloplop321 @ 5:39 pm

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.