In PHP, how do I map strings with examples?

Mapping, PHP, Strings, Arrays, Associative Arrays, Looping
This example illustrates how to map strings in PHP using arrays and associative arrays for efficient data handling.
<?php // Example of mapping strings to values in PHP // Basic array mapping $fruits = array( "apple" => "red", "banana" => "yellow", "grape" => "purple" ); // Displaying the mapped fruits and their colors foreach ($fruits as $fruit => $color) { echo "The color of $fruit is $color.<br>"; } // Example of using an indexed array $colors = array("red", "yellow", "purple"); // Mapping strings to their indexes foreach ($colors as $index => $color) { echo "Color at index $index is $color.<br>"; } ?>

Mapping PHP Strings Arrays Associative Arrays Looping