Skip to content

Commit

Permalink
Usando o array_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ojulio-dev committed Jan 29, 2025
1 parent 9f5e69f commit e7ec7f1
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,7 @@ function verificarSeEstaFinalizado($p) {

}

function filtro($itens, $funcao) {

$filtrados = [];

foreach($itens as $item) {


if ($funcao($item)) {

$filtrados[] = $item;

}

}

return $filtrados;

};

$projetosFiltrados = filtro($projetos, function($projeto) {
$projetosFiltrados = array_filter($projetos, function($projeto) {

return $projeto['ano'] === 2024 || $projeto['ano'] === 2021;

Expand Down

0 comments on commit e7ec7f1

Please sign in to comment.