diff --git a/index.php b/index.php index bcf87ff..076f418 100644 --- a/index.php +++ b/index.php @@ -29,19 +29,13 @@ 'purchaseUrl' => 'http://example.com' ] ]; + $filteredItems = array_filter($books, function($book) { + return $book['author'] == 'Andy Weir'; + }); - function filterByAuthor($books, $author){ - $filteredBooks = []; - foreach($books as $book) { - if ($book['author'] === $author) { - $filteredBooks[] = $book; - } - } - return $filteredBooks; - } ?>