PHP associative vs numeric arrays [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, August 10, 2023

PHP associative vs numeric arrays [duplicate]

While working with arrays, I came to a fundamental question about arrays in PHP:

$ar1 = [ '0' => 1, '1' => 2 ];
$ar2 = [ 1, 2 ];

print_r($ar1 === $ar2); // 1

So, does this mean, that numeric arrays are basically associative arrays? Are they implemented the same way? Or can you assume any numeric array to pretty much be a special case of an associative array?



source https://stackoverflow.com/questions/76870311/php-associative-vs-numeric-arrays

No comments:

Post a Comment