qiuqiux/ indexed-array
基于SplFixedArray重写,可以用作索引数组。
v1.0.1
2016-07-06 04:11 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-14 18:42:21 UTC
README
从SplFixedArray修改,可以用作数组。
示例
$a = new IndexedArray();
$a[] = 'a';
$a[] = 'b';
$a[] = 'b';
$a->pop();
$a->shift();
foreach ($a as $val) {
echo $val;
}
echo count($a); // 1
$a[] = 'd'; // $a[1] = 'd';
$indexedArray1 = new IndexedArray();
$indexedArray2 = new IndexedArray();
$max = 1000000;
for ($i = 0; $i < $max; ++$i) {
$indexedArray1[] = $i;
$indexedArray2[] = $max + $i;
}
echo $indexedArray1->merge($indexedArray2)->getSize();
API
- createFormArray
- createFromFixedArray
- pop
- push
- shift
- unshift
- unique
- last
- search
- transform
- reverse
- merge
- getSize
- toJson
- toArray