Array that is becoming object [closed]

0

When using the json decode function in a json, I'm having a problem. When the numbering is perfectly in order (0,1,2,3 ...) it is classified as arra:

[2016-08-01] => Array
    (
        [0] => 07:00:00
        [1] => 07:20:00
        [2] => 07:40:00
        [3] => 08:00:00
        [4] => 08:20:00
        [5] => 08:40:00
        [6] => 09:00:00
        [7] => 09:20:00
        [8] => 09:40:00
        [9] => 10:00:00
        [10] => 10:20:00
        [11] => 10:40:00
        [12] => 11:00:00
    )

However, when I need to remove some schedules it automatically becomes an object (I removed the element of index 9 and 10)

[2016-07-25] => stdClass Object
        (
            [0] => 07:00:00
            [1] => 07:20:00
            [2] => 07:40:00
            [3] => 08:00:00
            [4] => 08:20:00
            [5] => 08:40:00
            [6] => 09:00:00
            [7] => 09:20:00
            [8] => 09:40:00
            [11] => 10:40:00
            [12] => 11:00:00
        )

I would like to know how to prevent this from occurring, or if not, pass all my data to object, or all data to array.

    
asked by anonymous 20.07.2016 / 19:31

1 answer

2

Friend before using object forces cast to array with

$meu_array = (array)$obj;

So it will always be array.

    
20.07.2016 / 23:06