不希望重新排序PHP数组中的键

I have a quick question. When building an associative array key casting rules mean that strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. (On the other hand "08" will not be cast, as it isn't a valid decimal integer.) See for example: http://php.net/manual/en/language.types.array.php

The problem I have is that my keys are mixed integer and string .. meaning that when the associative array is built, all keys are reordered with numerical keys appear first before string. This is a sample of what I get in my console log:

...
2032: "9371.84"
2033: "9351.60"
2034: "9331.36"
2035: "9311.12"
ID: "1"
Misc1: "Russian Federation - Conventional"
Misc2: "RUS.Con1"
Misc3: "4"
Misc4: ""
...  etc.

How can I avoid this issue, so that the associative array does not re-order my keys?

As an FYI, this is how I generate my array in PHP:

while ($array = mysqli_fetch_assoc($result)) {
$experiment[] = $array;
};

Thank you for your time, G.

The workaround for the issue I have found is to avoid the associative array structure. This is what my loop looks like now:

while ($array = mysqli_fetch_assoc($result)) {
$experiment[0] = array_keys($array);
$experiment[] = array_values($array);
};

The annoying thing is that $experiment[0] = array_keys($array); gets looped uneccessarily... but at least I get the result that I am looking for and the keys are not cast and re-ordered by the associative array.

If anybody knows how to avoid the unecessary looping for $experiment[0], then please let me know :-)

Adding an index to an array in PHP like this:

$array[] = ['another array'];

Will increment the indexes.

You can however specify a string for the key, or cast the integers to strings.