Filter and format with arrays
Use array_filter and array_map to list the students who passed.
intermediatePHP / Laravel· PHP & Laravel
The task
Given an array of students with their scores:
- Keep only the students who passed (score ≥ 70) with
array_filter. - Turn each one into a line like "Dara: 85" with
array_map. - Print the lines, one per line, then "Passed: 3 of 5".
PHP doesn't run in the browser here: write it, ask the AI tutor to review it, and run it on your computer with php file.php.
What you'll build
The finished result. Try it out, then build it yourself below.
Demo · drag the bottom edge to make it taller