php tutorials -> loops in php

 19-loops.php


<?php

// echo 1;
// echo '</br>';
// echo 2;
// echo '</br>';
// echo 3;
// echo '</br>';

for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}
// (intilise, conditon;after executing what have to )
// break
// continue skip that iteration
$i = 1;
while ($i < 6) {
echo $i;
$i++;
}

// do while
$i = 1;

do {
echo $i;
$i++;
} while ($i < 6);

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $x) {
if ($x == "blue") continue;
echo "$x <br>";
}

$members = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

foreach ($members as $keys => $values) {
echo "$keys : $values <br>";
}

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $x) {
if ($x == "blue") $x = "pink";
}

var_dump($colors);
?>

=

No comments:

Post a Comment

Image upload in laravel

 = if($images !== null) { $images_array=[]; foreach ($images as $image) { $data=ImageUpload::instan...