Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created May 23, 2017 04:52
Show Gist options
  • Select an option

  • Save YurePereira/9545ff83283e41803827dc75e47c6099 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/9545ff83283e41803827dc75e47c6099 to your computer and use it in GitHub Desktop.
Usando o laço de repetição FOR, percorrendo um array.
<?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;
}
@YurePereira
Copy link
Author

YurePereira commented May 23, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment