Example 1 — Setting a Default for a List of Keys
Give each key in a list the same starting value.
<?php
$flags = array_fill_keys(['a', 'b', 'c'], 0);
print_r($flags); How It Works
- The values 'a', 'b' and 'c' of the first array become the keys.
- Every key receives the same value, 0.
- The order of the keys matches the order of the input list.
- print_r() shows the three keys with the value 0.

