3v4l.org

run code in 300+ PHP versions simultaneously
<?php $total = 7; $array = [1, 2]; // Dynamic, will be what you get from db. $array += array_fill(count($array), $total - count($array), 'empty'); var_dump($array);

preferences:
54.18 ms | 402 KiB | 5 Q