iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

August 8, 2008
Reader Question: What graphics compression program do you use?
About
 
August 7, 2008
Google's Big Mistake: Getting Rid of Google Page Creator, What Do...
About
 
August 7, 2008
Wish XML a happy birthday
About
 
August 7, 2008
Poll: How important is SEO to your overal website strategy?
About
 
August 7, 2008
How to Create a Search Feature with PHP and MySQL
WebReference.com
 
August 7, 2008
1 comment
.net
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /Introduction to PHP

Loop functions 

  Views:    2638
  Votes:    1
by John Doe 12/12/03 Rating: 

Synopsis:

This article show the most pratic (and most used) way for making actions in great scale.
Pages: 
The Article

What would you do if you had to show like, 50 random numbers. Write 50 lines of code? No! You can use loop functions.Loop functions are the most pratic wau for making actions in great scale (in this case, generating random numbers).

Let's see the random numbers script.

<?php
// The number of actions (the number of random numbers)
$total = 50;

// The "trick"
for($i = 1; $i <= $total; $i++) {
echo "Random number ".$i.": ".rand(1, 99999)."<br>";
}
?>



This must generate 50 random numbers, in just 3 lines!
Obs.: see more about random numbers at
http://www.devpapers.com/article/37

Very simple no? You can also use this dinamically, in a great number of cases.


Useful links:

www.php.net/for
www.php.net/while
www.php.net/rand

Pages: 



 
  Sponsors