cef8fcc6e3
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.
15 linhas
384 B
PHP
15 linhas
384 B
PHP
<?php
|
|
function cmp($a, $b) {
|
|
$a = preg_replace('@^(a|an|the) @', '', $a);
|
|
$b = preg_replace('@^(a|an|the) @', '', $b);
|
|
return strcasecmp($a, $b);
|
|
}
|
|
|
|
$array = array("John" => 1, "the Earth" => 2, "an apple" => 3, "a banana" => 4);
|
|
$arrayObject = new ArrayObject($array);
|
|
$arrayObject->uksort('cmp');
|
|
|
|
foreach ($arrayObject as $key => $value) {
|
|
echo "$key: $value\n";
|
|
}
|