answersLogoWhite

0

There are a number of different ways to loop using PHP. They're as follows:

  • For
  • Foreach
  • While
  • Do-while

Below are some examples of how each of these types of loop work.

For

for ($x = 0; $x < 100; $x++) {

echo $x.'
';

}

?>

Foreach

$array = array(1, 5, 8, 2, 9);

foreach ($array as $number) {

echo $number.'
';

}

?>

While

while ($x < 10) {

$x++;

echo $x.'
';

}

?>

Do-while

do {

$x++;

echo $x.'
';

} while ($x < 10);

?>

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Why do we use Php?

PHP is an Open Source Scripting Language. We can create Web Pages and Web Applications using PHP.


How do you create a web mail script using PHP?

You can use phpMailer() Or, you can use mail() PHP function to send emails via PHP script.


How can you create a loop using a knot?

To create a loop using a knot, you can make a simple overhand knot in a rope or string and leave a small loop at the end. This loop can be used for various purposes such as attaching a hook or securing an object.


How do you print 1 to 100 without using loop in php?

The best way to print the numbers 1 to 100 in PHP without using a loop is with the following code: echo implode("&lt;br&gt;", range(1,100)); You can replace the &lt;br&gt; with anything that you want to separate the numbers, such as dashes. I used a line-break in the example.


How do you make a blog using PHP and MySQL?

You can create blog in php. In fact, many blogs on the internet created using php. There are many readymade blogs which you can install on your own server. Or, if you wish, you can create your own blog application. Simply, blog is a dynamic website (users can add, delete, update content) and PHP was designed for creation of dynamic websites.


Why is PHP used?

PHP is used to create dynamic websites, this is a step up from HTML as it allows you to do much more than creating static websites. Using a language such as PHP also gives you access to using databases with your website such as MySQL.


Which loop is used in php?

while, do...while, for, foreach are used


How can I create a seamless loop in After Effects?

To create a seamless loop in After Effects, you can duplicate your footage, offset the timing of the duplicate, and blend the two together using keyframe animation. This will create a continuous loop without any noticeable breaks or jumps.


How do you create a DIV type file using PHP?

A file with the DIV file extension is a DivX Movie file, it cannot be created with PHP. PHP is a web programming language for web site building.


How can you create a website without using a host like Shutterfly?

Maybe try mySQL or PHP?


How do you create a redirect webpage?

If you are using PHP you could use this code: (In the &lt;head&gt;) &lt;?php HEADER("Location: http://www.rasclerhys.com"); ?&gt; That should automatically take you to "www.rasclerhys.com"


How can I use the ffmpeg loop feature to create a continuous video loop?

To create a continuous video loop using the ffmpeg loop feature, you can use the &quot;loop&quot; option in the ffmpeg command followed by the number of times you want the video to loop. For example, you can use the command &quot;ffmpeg -streamloop -1 -i input.mp4 output.mp4&quot; to loop the video indefinitely.