Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Last active May 23, 2017 22:25
Show Gist options
  • Select an option

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

Select an option

Save YurePereira/f5b6c0896715b27a62b8d6d5e9032777 to your computer and use it in GitHub Desktop.
Usando o laço de repetição FOREACH, segunda sintaxe.
<?php
$frults = array(
'Pineapple',
'Cashew',
'Apple',
'Strawberry'
);
foreach ($frults as $key => $value) {
echo 'Chave: ' . $key . ', Valor: ' . $value . PHP_EOL;
}
/*
Saída:
Chave: 0, Valor: Pineapple
Chave: 1, Valor: Cashew
Chave: 2, Valor: Apple
Chave: 3, Valor: Strawberry
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment