Closed
Description
Description
The following code:
<?php
class array_test
{
public $array = array();
public function __construct()
{
$this->array = array(
'1696007099_5_d386ca263816163166823ef00979d944' => array(
'order' => 1
),
'1663066269_5_8c82ae69264d73f7ae7ce3a619501231' => array(
'order' => 0
)
);
uksort($this->array, function ($a, $b)
{
return $this->array[$a]['order'] - $this->array[$b]['order'];
}
);
}
}
new array_test;
Resulted in this output:
Warning: Undefined array key "1696007099_5_d386ca263816163166823ef00979d944" in .../array_test.php on line 19
But I expected this output instead:
No warnings/errors, just a freshly sorted array.
I have tested the following:
echo $a; // 1696007099_5_d386ca263816163166823ef00979d944
echo $b; // 1663066269_5_8c82ae69264d73f7ae7ce3a619501231
echo array_key_exists($a, $this->array); // FALSE
echo isset($this->array[$a]); // FALSE
echo array_key_first($this->array); // 1696007099_5_d386ca263816163166823ef00979d944
echo array_keys($this->array)[0]; // 1696007099_5_d386ca263816163166823ef00979d944
PHP Version
PHP 8.3
Operating System
CentOS 7.9