PHP arrays and memory allocation

A random question that crossed my mind:
If I define an array in PHP like this:

$arr = Array();
$arr[7392171] = "some value";

How is it stored inside? Does key 7392171 display “some value” or does it work like JavaScript and put 7392170 empty values ​​in front of it?
I guess this is the first because indexed and associative arrays are the same (at least from my understanding) and comparable to objects in JavaScript.
So yes, just interesting :)

+3
source share
2 answers

check it with var_dump($arr)

if he created 739217 empty values, you will see this.

greetings :)

+3

PHP. .

- , ?

0

Source: https://habr.com/ru/post/1775764/


All Articles