This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
// Aqui a array no caso pode ser um json de uma api | |
//$users = json_decode ( file_get_contents( ), true ); | |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
foreach ( $users as $ValorQueVaiCorrer ){ | |
print_r($ValorQueVaiCorrer); | |
} | |
?> |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
foreach ( $users as $ValorQueVaiCorrer ){ | |
print_r( $ValorQueVaiCorrer ); | |
} | |
// saída |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
foreach ( $users as $ValorQueVaiCorrer ){ | |
echo ($ValorQueVaiCorrer["nome"]."\n"); | |
} |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
return $val; | |
}// Isso é uma função pura :) |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
return $val; | |
}// Isso é uma função pura :) |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
return $val; | |
}// Isso é uma função pura :) |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
return $val[ 'nome' ]; | |
}// Isso é uma função pura :) |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcos ' ], | |
[ 'idade' => 50, 'nome' => 'Marcelo dougras' ], | |
]; | |
function passa ( $val ){ | |
$saida = 'Marco';// isso abaixo é tudo o que começar com $saida | |
return substr( $val[ 'nome' ], 0, strlen($saida)) == $saida ? $val : false; |
This file contains 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function passa ( $val, $w ){ | |
$val["idade"] += $w["idade"];// aqui ele vai pegar o valor do array e irá somar. | |
return $val; |
OlderNewer