1

At the moment I have a while loop as so:

while($row_hours = $getHours->fetch_assoc()) {
    $hours[] = $row_hours;
}

The output is:

Array
(
[0] => Array
    (
        [day] => Mon
        [open] => 09:00:00
        [close] => 17:00:00
        [closed] => 0
    )

[1] => Array
    (
        [day] => Tue
        [open] => 09:00:00
        [close] => 17:00:00
        [closed] => 0
    )

I would like to move the day key to be the name of the sub-array. So the output looks like this:

    Array
(
[Mon] => Array
    (
        [open] => 09:00:00
        [close] => 17:00:00
        [closed] => 0
    )

[Tue] => Array
    (
        [open] => 09:00:00
        [close] => 17:00:00
        [closed] => 0
    )

Is this at all possible? I have tried everything I can think of and I either get an error or it just gives me numbers.

Anyone's help or suggestions would be greatly appreciated.

Tom C
  • 11
  • 3

0 Answers0