Answers for "how to loop therough php"

PHP
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
0

php iterate through a loop

<?php
 
$scores = [1,2,3];
foreach ($scores as $score) {
 echo $score;
}
Posted by: Guest on April-26-2020

Browse Popular Code Answers by Language