fork download
  1. <?php
  2. $mysql = array( '01', '03', '04', '06', '11' );
  3.  
  4. $max = max(12, max($mysql));
  5.  
  6. $final = array();
  7.  
  8. for ($i = 1; $i <= $max; $i++) {
  9.  
  10. $current = str_pad($i, 2, '0', STR_PAD_LEFT);
  11.  
  12. if (in_array($current, $mysql)) {
  13. $final[] = $current;
  14. } else {
  15. $final[] = '00';
  16. }
  17. }
  18.  
  19. print_r($final);
Success #stdin #stdout 0.01s 23892KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 01
    [1] => 00
    [2] => 03
    [3] => 04
    [4] => 00
    [5] => 06
    [6] => 00
    [7] => 00
    [8] => 00
    [9] => 00
    [10] => 11
    [11] => 00
)