💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## get ``` $data = [ 'fruit' => [ 'apple' => 2, 'orange' => 1, 'grape' => 4 ], 'color' => [ 'red' => 12, 'blue' => 8, 'green' => 6 ] ]; $splArray = new \EasySwoole\Spl\SplArray($data); var_dump($splArray->get('fruit.apple')); //2 ``` ## set ``` $splArray->set('fruit.apple', 3); ``` ## __toString ``` var_dump($splArray->__toString()); //转 json ``` ## unset / delete 效果相同 ``` $splArray->delete('fruit.apple'); ``` ## unique 移除数组中重复的值 ``` $data = [ 'apple' => 2, 'orange' => 1, 'grape' => 2, 'pear' => 4, 'banana' => 8 ]; $splArray = new \EasySwoole\Spl\SplArray($data); var_dump($splArray->unique()->getArrayCopy()); ``` ## multiple 获取数组中重复的值 ``` $data = [ 'apple' => 2, 'orange' => 1, 'grape' => 2, 'pear' => 4, 'banana' => 8 ]; $splArray = new \EasySwoole\Spl\SplArray($data); var_dump($splArray->unique()->multiple()); ``` ## column ``` var_dump($splArray->column('apple')->getArrayCopy()); ``` ## flip 键值对 ## toXML 转成 xml