Skip to content

Commit

Permalink
O que são filtros?
Browse files Browse the repository at this point in the history
  • Loading branch information
ojulio-dev committed Jan 29, 2025
1 parent fe3ccc3 commit e27a68b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"data" => "2024-05-11",
"descricao" => "Lista de Tarefas. Escrito em PHP e HTML."
],
[
"titulo" => "Controle de Leitura de Vídeos",
"finalizado" => true,
"data" => "2024-05-11",
"descricao" => "Lista de Livros. Escrito em PHP e HTML."
],
[
"titulo" => "Mais um Projeto",
"finalizado" => false,
"data" => "2025-05-11",
"descricao" => "Projeto secreto em andamento. Escrito em PHP e HTML."
],
// "Lista de Tarefas",
// "Controle de Leitura de Livros",
// "mais um projeto",
Expand All @@ -58,6 +70,31 @@ function verificarSeEstaFinalizado($p) {
return '<span style="color: green;">⛔ não finalizado</span>';

}

function filtarProjetos($listaDeProjetos, $finalizado = null) {

if (is_null($finalizado)) {

return $listaDeProjetos;

}

$filtrados = [];

foreach($listaDeProjetos as $projeto) {


if ($projeto['finalizado'] === $finalizado) {

$filtrados[] = $projeto;

}

}

return $filtrados;

}

?>

Expand All @@ -71,7 +108,7 @@ function verificarSeEstaFinalizado($p) {

<ul>

<?php foreach($projetos as $projeto): ?>
<?php foreach(filtarProjetos($projetos, false) as $projeto): ?>

<div

Expand Down

0 comments on commit e27a68b

Please sign in to comment.