Functions & Arrays · 8 min read · Beginner
Arrays, array_filter & array_map
Work with indexed and associative arrays and transform collections cleanly using PHP 8 arrow functions (fn).
What you'll learn
- Create and read associative arrays with ['key' => 'value']
- Transform and filter arrays cleanly using array_map() and array_filter()
- Write concise PHP 8 arrow functions using fn($x) => ...
PHP arrays work as both ordered lists (['HTML', 'CSS']) and key-value maps (['title' => 'PHP', 'free' => true]). Combine them with array_filter(), array_map(), and short arrow functions (fn($x) => ...).
Fill-in-the-Blank Exercise
Filter Passing Scores
Filter $scores using array_filter and a PHP arrow function.
$passing = ($scores, ($s) => $s >= 80);Try It Yourself
PHPAssociative Arrays & Arrow Functions
PHP 8 Output (WebAssembly)
Click Run PHP to execute real PHP 8 right in your browser.
Check Your Understanding
Score: 0 / 1
1. Which keyword creates a short single-expression arrow function in PHP?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.