Skip to content

Instantly share code, notes, and snippets.

@MubinSayed
Last active October 2, 2018 05:17
Show Gist options
  • Save MubinSayed/72377cc0f0ace3201b3b986aae83da03 to your computer and use it in GitHub Desktop.
Save MubinSayed/72377cc0f0ace3201b3b986aae83da03 to your computer and use it in GitHub Desktop.
<?php
$fruits = array('apple', 'mango', 'grape', 'orange');
echo 'Do While Loop Example <br>';
$i = 0;
do{
echo ('I am '.$fruits[$i].'.<br>');
$i++;
}while( $i < count($fruits) )
?>
<?php
$fruits = array('apple', 'mango', 'grape', 'orange');
echo 'For Loop Example <br>';
for($i = 0; $i< count($fruits); $i++){
echo ('I am '.$fruits[$i].'.<br>');
}
echo '<hr>';
?>
<?php
$fruits = array('apple', 'mango', 'grape', 'orange');
echo 'Foreach Loop Example <br>';
foreach($fruits as $fruit){
echo ('I am '.$fruit.'.<br>');
}
?>
<?php
$fruits = array('apple', 'mango', 'grape', 'orange');
echo 'While Loop Example <br>';
$i = 0;
while( $i < count($fruits) ){
echo ('I am '.$fruits[$i].'.<br>');
$i++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment