<?php
$fruits[0] = 'Apple';
$fruits[0] = 'Orange';
echo $fruits [0];
?>
Orange appears on the screen. Because the value of the 0 key of the $fruits
array was changed from Apple to Orange on the next line.
We’ve always shown it with numeric keys, now let me show it with the string keys:
<?php
$guest['name'] = 'Baransel';
$guest['age'] = 20;
$guest['country'] = 'Romania';
echo 'Guests name is ' . $guest['name'] . ', age is ' . $guest['age'] . ', and country is ' . $guest['country'] . '.';
?>
This will print out:
Guests name is Baransel, age is 20, and country is Romania.