@for loop php
#Loops
<?php
#loops execute code a set number of times
/*
Types of loops
1-For
2-While
3-Do..while
4 Foreach
*/
# For Loop usually use if you know the number of times it has to execute
# @params -it takes an init, condition, increment
#for($i =0;$i<=11;$i++){
#echo 'Number: '.$i;
#echo '<br>';
#}
#While loop
# @ prams - condition
#$i = 0;
#while($i < 10){
# echo $i;
# echo '<br>';
# $i++;
#}
# Do...while loops
#@prapms - condition
/*$i = 0;
do{
echo $i;
echo '<br>';
$i++;
}
while($i < 10);*/
# Foreach --- is for arrays
# $people = array('Brad', 'Jose', 'William');
# foreach($people as $person){
# echo $person;
# echo '<br>';
# }
$people = array('Tony' => '[email protected]',
'Jose' => '[email protected]','William' => '[email protected]');
foreach($people as $person => $email){
echo $person.': '.$email;
echo '<br>';
}
?>/*
For loop in php
*/
<?php
for ($i = 0; $i < 10; $i++) {
echo $i."<br>";
}
?>
Also in PHP:
- check key exist array php
- array key exists function in php
- convert date and time to timestamp php
- Connecting objects PHP MYPHPSQL
- PHP Warning: Module 'soap' already loaded in Unknown on line 0
- carbon add minutes
- ::contains php
- !is_null in laravel
- console.log en php
- creat laravel project
- core php redirect to page
- date convert string timestamp to date php
- Undefined offset: 0 at laravel\framework\src\Illuminate\Routing\Router.php
- convert timestamp to readable date and time
- check if string contain element php
- auto clear cache laravel
- check multiple permission laravel spatie
- artisan clear cahce
- Allowed memory size of 1610612736 bytes exhausted laragon
- divisible by 2 php output numbers
- date("H:i:s"); is js or php
- What is a Regular Expression in php
- creating a laravel project with composer
- data() php