Cause I need some help. I'm a PHP n00b, and we are doing loops for class, and I have no idea what the hell I am doing so any help would be much appreciated.
							
						
					Announcement
				
					Collapse
				
			
		
	
		
			
				No announcement yet.
				
			
				
	
Web Developers! Where you at?
				
					Collapse
				
			
		
	X
- 
	
	
	
		
	
	
		
		
		
		
		
		
		
	
	
 This is what I have to do.Originally posted by Pir8 97 View PostAfraid I'm more design and front-end stuff (CSS, HTML, etc.). What's your question, maybe I can help find the answers?
 4. Take the array from exercise 3 and display it using 1) a for loop, 2) a while loop, and 3) a do-while loop. Display what type of loop you used before the output, and put each loop in its own paragraph.
 NOTE: Remember the semicolon at the end of the do-while loop! Also, remember to use $index++ in your while and do while loops or they won't increment! (and your browser will crash).
 
  
 I've got a PHP book in front of me, but I need to display 3 things using a for loop and I can't get it to do it, I can make it display 1, but not 3 its quite frustrating.Originally posted by eskimopunk View PostW3?- Kielan (Key-lin)
 Comment
- 
	
	
	
		
	
	
		
		
		
		
		
		
		
	
	
 
 PHP Lab 7 
 
 Example 1
 
 echo "Hello World! ";
 ?>
 
 Example 2
 $room_num = "208 IST";
 $time = "4:15-5:30";
 $professor = "Dr. Aungst";
 $section = 556201;
 define("COURSE", "IST 210");
 
 echo $room_num;
 echo "
 ";
 var_dump ($time);
 echo "
 ";
 print_r ($professor);
 echo "
 ";
 echo $section;
 echo "
 ";
 echo COURSE;
 ?>
 
 Example 3
 
 $animals[0] = "cow";
 $animals[1] = "dolphin";
 $animals[2] = "elephant";
 
 echo "\$dbms = ". $animals[0];
 echo "
 ";
 echo "\$mysql = ". $animals[1];
 echo "
 ";
 echo "\$php = ". $animals[2];
 echo "
 ";
 ?>
 
 Example 4
 
 echo "For Loop ";
 for ($animals=0;$animals<=2; $animals++);
 {
 echo "$animals. cow
 ";
 }
 ?>
 
 - Kielan (Key-lin)
 Comment
- 
	
	
	
		
	
	
		
		
		
		
		
		
		
	
	
 Try this
 
 For
 $elements = count($animals) - 1;
 for ($i = 0; $i <= $elements; $i++) {
 echo $animals[$i] . '
 ';
 }
 
 
 While
 $elements = count($animals) - 1;
 $i = 0;
 while ($i <= $elements) {
 echo $animals[$i] . '
 ';
 $i++;
 }
 
 
 do while
 $elements = count($animals) - 1;
 $i = 0;
 do {
 echo $animals[$i] . '
 ';
 $i++;
 } while ($i <= $elements);
 
 
 Courtesy of my favorite programmer.Will design/build websites for wheels 
  
 Comment


 
							
						
Comment