Arquivos
hhvm/hphp/test/slow/array_object/uasort.php
T
Paul Tarjan cef8fcc6e3 add ArrayObject
This is a pure PHP implementation of ArrayObject. It does't match the reference semantics of zend's implementation, but it is much easier to build this in pure PHP, so its a good first step. It is better to have it like this, than to not have it at all.
2013-05-24 09:48:22 -07:00

27 linhas
416 B
PHP

<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
// Array to be sorted
$array = array(
'a' => 4,
'b' => 8,
'c' => -1,
'd' => -9,
'e' => 2,
'f' => 5,
'g' => 3,
'h' => -4,
);
$arrayObject = new ArrayObject($array);
print_r($arrayObject);
// Sort and print the resulting array
$arrayObject->uasort('cmp');
print_r($arrayObject);