文件名称:iter-master生成器提供迭代原语的PHP库.zip
文件大小:20KB
文件格式:ZIP
更新时间:2022-07-31 05:01:17
类库下载-iter-master生成器提供迭代原语的PHP库
<?php namespace iter; use iter\fn; use PHPUnit\Framework\TestCase; class IterFnTest extends TestCase { public function testIndex() { $getIndex3 = fn\index(3); $getIndexTest = fn\index('test'); $arr1 = [10, 11, 12, 13, 14, 15]; $arr2 = ['foo' => 'bar', 'test' => 'tset', 'bar' => 'foo']; $this->assertSame($arr1[3], $getIndex3($arr1)); $this->assertSame($arr2['test'], $getIndexTest($arr2)); } public function testNestedIndex() { $getIndexFooBar = fn\nested_index('foo', 'bar'); $getIndexFooBarBaz = fn\nested_index('foo', 'bar', 'baz'); $getEmptyIndex = fn\nested_index(); $array = [ 'foo' => [ 'bar' => [ 'baz' => 42 ] ] ]; $this->assertSame($array['foo']['bar'], $getIndexFooBar($array)); $this->assertSame($array['foo']['bar']['baz'], $getIndexFooBarBaz($array)); $this->assertSame($array, $getEmptyIndex($array)); }这是一个生成器提供迭代原语的PHP库,需要的朋友可以直接下载使用,十分的方便。