Answers for "How to write a loop in PHP"

PHP
26

for loop php

<?php
	$fruits = ["apple", "banana", "orange"];
	for($i=0;$i<count($fruits);$i++){
    echo "Index of ".$i."= ".$fruits[$i]."<br>";
    }
  ?>
Posted by: Guest on December-28-2019
1

How to write a loop in PHP

<?php

//FOR each item within the array, "ECHO" out the index ($i) and value of each item.
$numbersArray = [1, 2, 3]
for($i = 0; $i < count($numbersArray); $i++) {
	echo "Index of ".$i."= ".$numbersArray[$i]."<br>";
}

?>
Posted by: Guest on March-16-2022
3

for loop in php

for($i = 0;$i < count($users);$i++) {

    if($users[$i]['user_id']==3){

        $userName = $users[$i]['first_name'];

    }

}
Posted by: Guest on January-08-2022
0

php for loop

for($i = 1; $i > 10; $i++){
  //show i value
	echo "Your Number Is :$i";
}
Posted by: Guest on September-03-2021
0

php loop

/*teting*/
Posted by: Guest on February-04-2022

Code answers related to "How to write a loop in PHP"

Browse Popular Code Answers by Language