Array walk function
📖 Scenario: You have a list of fruits with their prices. You want to increase each fruit's price by 10% to prepare for a sale.
🎯 Goal: Use the PHP array_walk function to update each fruit's price by increasing it by 10%.
📋 What You'll Learn
Create an associative array called
fruits with exact keys and valuesCreate a function called
increasePrice that increases the price by 10%Use
array_walk with increasePrice to update the pricesPrint the updated
fruits array💡 Why This Matters
🌍 Real World
Increasing prices or applying discounts to product lists is common in online stores and inventory management.
💼 Career
Understanding how to manipulate arrays with functions like <code>array_walk</code> is useful for backend PHP developers working with data transformations.
Progress0 / 4 steps