Question: I have been trying to set up an array contain time on the hour of half an hour like 7:00, 7:30 and so forth. However my array does not take in values like 7:0 or 8:0 but just 7:30 and 8:30. I can echo everything but cant insert value on array

```
<?php
    $arr=[];
    $n=0;
for($i=7;$i<=16; $i++)
{

    for($x=0;$x <31;$x++)
    {
            if($x===0 || $x===30)
            {
                echo $i. ":".$x . "\n";
                $arr[$n]= $i. ":".$x;
            }

    }
    $n++;
}

?>

```

Answer: 
Your problem is that you are incrementing `$n` outside your `for ($x...` loop, so the `$i:30` value overwrites the `$i:0` value. But your code is far more complex than it needs to be, try this instead:

```
$arr=[];
for($i=7;$i<=16; $i++) {
    $arr[] = "$i:00";
    $arr[] = "$i:30";
}
print_r($arr);

```

Output:

```
Array
(
    [0] => 7:00
    [1] => 7:30
    [2] => 8:00
    [3] => 8:30
    [4] => 9:00
    [5] => 9:30
    [6] => 10:00
    [7] => 10:30
    [8] => 11:00
    [9] => 11:30
    [10] => 12:00
    [11] => 12:30
    [12] => 13:00
    [13] => 13:30
    [14] => 14:00
    [15] => 14:30
    [16] => 15:00
    [17] => 15:30
    [18] => 16:00
    [19] => 16:30
)

```

[Demo on 3v4l.org](https://3v4l.org/I1dJU)
You should specify the number of digits using str\_pad

```
    $arr= array();;
    $n=0;
    for($i=7;$i<=16; $i++)
    {
    for($x=0;$x <31;$x++)
    {
            if($x===0 || $x===30)
            {
                $k = str_pad($x,2,"0",STR_PAD_LEFT);
                echo $i. ":".$k . "\n";
                $arr[$n]= $i. ":".$x;
            }
    }
    $n++;
}

```