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.

2
  • 3
    yes you can. give us what you have tried so far? and also expected outcome too Commented Feb 10, 2017 at 15:02
  • Any name, or something specific? Commented Feb 10, 2017 at 15:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.