Trivial question.
Suppose I have the following code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$words = ['Apple', 'Avocado', 'Banana', 'Blueberry'];
$dict = [];
// build a dictionary keyed on the first letter
foreach ($words as $word) {
$letter = $word[0];
// is this condition necessary?
if (!isset($dict[$letter])) {
$dict[$letter] = [];
}
$dict[$letter][] = $word;
}
?>
Usually when I build a dictionary, before appending an entry, I ensure that the array exist as shown in my example.
I always thought a warning would show up otherwise, however it does not seem to be the case.
So is the IF condition necessary?