Friday, 18 February 2011

Testing PHP Continued

Some of the functions I have been learning for loops, arrays, if statements:

What to do next: Parsing RSS/XML files through similiar functions as to bellow using variables from the RSS file:
= 0){
 echo "
counter is zero or greater
"; } else{ echo "
counter is less than zero
"; } //this is a test for a loop, in whicch it adds one to the counter untill it reaches four while($counter < 4){ $counter=$counter+1; echo "
I now have $counter bits of paper
"; if ($counter == 2){ echo "
"; } } //this is a test for displaying an image depending on the time, if after 6pm display a night image, if not display a day image if ($current_time >= 18){ echo "
"; } else{ echo "
"; } //printing an element in an array in this case $food //echo $food[1]; //echo $food[$foodarraycounter]; while($foodarraycounter<4){ //echo $food[$foodarraycounter]; if($food[$foodarraycounter]=="soup"){ //echo "working"; echo "
"; } // if the food array counter corresponds to orange print the image if($food[$foodarraycounter]=="orange"){ echo "
"; } // this is the loop function in which it pluses one untill it reaches the parameters of the if statement and prints the corresponding image $foodarraycounter=$foodarraycounter+1; } ?>

No comments:

Post a Comment