|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 02:00:01 2025 UTC |
Description: ------------ Some Datastructures like SplFixedArray and SplObjectStorage could have a sort method where we can pass an optional callback and it sorts the original object or even return a new one. Test script: --------------- <?php $array = new SplFixedArray(10); for ($i = 0; $i < 10; $i++) { $array[$i] = mt_rand(1, 10); }; $array->sort(); $array->sort(function ($a, $b) { return $b - $a; }); /** * Or: * $newArray = $array->sort(); */ Expected result: ---------------- A sorted SPL Datastructure Actual result: -------------- FATAL ERROR Uncaught Error: Call to undefined method SplFixedArray::sort()