Created
May 23, 2017 04:52
-
-
Save YurePereira/9545ff83283e41803827dc75e47c6099 to your computer and use it in GitHub Desktop.
Usando o laço de repetição FOR, percorrendo um array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Array de elemento | |
| $myArray = array(0, 1, 2, 3, 4); | |
| //Iterando item por item do Array $myArray | |
| for ($i = 0; $i < count($myArray); $i++) { | |
| echo 'Item índice: ' . $i . ', Valor: ' . $myArray[$i] . PHP_EOL; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Saída do código:
Item índice: 0, Valor: 0
Item índice: 1, Valor: 1
Item índice: 2, Valor: 2
Item índice: 3, Valor: 3
Item índice: 4, Valor: 4