Skip to content
Omni Academy
Search courses and lessons
Search
Courses
Backend Development
9
Databases
1
Frontend Development
5
Data Science
5
All courses →
Playground
HTML & CSS
JavaScript
TypeScript
Python
PHP
Ruby
Light
Dark
Auto
Sign in
Get started
All
Backend Development
Databases
Frontend Development
Data Science
Playground
Blog
HTML
JS
TS
PY
PHP
RB
← Courses
📄
PHP basics
Run as I type
Reset
▶
Run
Ctrl
↵
PHP
PHP source code
<?php // A real PHP build compiled to WebAssembly. It runs in this tab, not on // a server, so nothing you type here leaves your browser. $learners = [ ["name" => "Aisha", "score" => 92, "level" => "advanced"], ["name" => "Kenji", "score" => 78, "level" => "intermediate"], ["name" => "Lena", "score" => 85, "level" => "expert"], ]; // Array functions read as the sentence they are. $passing = array_filter($learners, fn($l) => $l["score"] >= 80); echo "Passing: ", implode(", ", array_column($passing, "name")), "\n"; $average = array_sum(array_column($learners, "score")) / count($learners); printf("Average: %.1f\n", $average); // Destructuring in a foreach, and named keys. foreach ($learners as ["name" => $name, "level" => $level]) { printf("%-6s %s\n", $name, $level); } echo json_encode(["count" => count($learners)]), "\n";
Input
one line per
input()
call
Output
Rendered by your browser