Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $numbers = array(10,20,30,40);
- /**
- *
- * Fetch array with for loop
- */
- /**for($i=0; $i<4; $i++){
- echo "{$numbers[$i]}<br />\n";
- } **/
- /***
- * Fetch array with foreach loop
- * Foreach loop is specially develope for array
- */
- /**foreach($numbers as $number){
- echo $number . "<br />\n";
- } **/
- /****
- * Extract $key and $value in foreach loop from array
- */
- /**foreach($numbers as $key => $value){
- echo "Key: {$key}, Value: {$value}<br />\n";
- } **/
- /***
- * Fetch array with while loop
- */
- /***
- $i = 0;
- while($i<4){
- echo "{$numbers[$i]}<br />\n";
- $i++;
- }
- *
- * **/
- $i = 0;
- do{
- echo "{$numbers[$i]}<br />\n";
- $i++;
- }while($i<4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement