<?php $data = ["04" => 1, "09" => 1, "10" => 1, "01" => 1]; for ($x = 1; $x < 11; ++$x) { $key = sprintf("%02d", $x); // ensure proper padding with 0 $result[$key] = $data[$key] ?? 0; // null coalescing operator from php5.6+ } print_r($result);
You have javascript disabled. You will not be able to edit any code.