Why Modern PHP Matters
📖 Scenario: Imagine you are building a simple website that shows a list of your favorite movies. You want to use PHP to create this list and display it nicely on the page. Using modern PHP features will help you write cleaner, safer, and faster code.
🎯 Goal: You will create a PHP script that stores a list of movies, sets a minimum rating to filter good movies, uses a modern PHP loop to select movies above that rating, and finally prints the filtered list.
📋 What You'll Learn
Create an associative array called
$movies with exact movie titles as keys and their ratings as values.Create a variable called
$minRating and set it to 7.Use a
foreach loop with $title and $rating to filter movies with ratings greater than or equal to $minRating into a new array called $goodMovies.Print the
$goodMovies array using print_r.💡 Why This Matters
🌍 Real World
Filtering and displaying data is a common task in websites and apps, such as showing only good reviews or popular items.
💼 Career
Understanding modern PHP basics like associative arrays, loops, and filtering helps you write clean and efficient code used in many web development jobs.
Progress0 / 4 steps