Demonstrate the use of Loops and arrays in 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($i = 0; $i <=10; $i++){
echo "The index is $i";
}
Also in PHP:
- base64decode php
- datetimepicker format php
- composer and php version
- run php artisan cache:clear
- date with time in php
- check if logged laravel
- eloquent timestamps false
- call a seeder in database laravel
- disallow search engines
- Verzeichnis einlesen php
- Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
- csv to json php
- $e = array("red", "green", "blue"); echo intval($e) . "<br>";
- codeigniter get id after insert
- THROW EXPECTION PHP
- composer laravel install
- error_log wordpress
- date format ph
- array in array key values unique
- error php display
- cache set in laravel
- clear cache laravel in server
- Allowed memory size of 134217728 bytes exhausted (tried to allocate
- Undefined index: $fileName = basename($_FILES["file"]["name"]);file in D:\xampp\htdocs\upload.php on line 12