我在 中收集了一个数组Laravel,但为什么 result 中有一个索引?如何在不循环迭代的情况下删除索引,因为如果数据很大,循环会占用很多资源。
这是代码
public function test(){
$array = [ ["no"=>1],["no"=>2] , ["no"=>3], ["no"=>4] ] ;
$collection = collect($array);
$filtered = $collection->filter(function ($value, $key) {
return $value['no'] > 2;
});
return $filtered->all();
}
Run Code Online (Sandbox Code Playgroud)
这是数据结果
{
"2": {
"no": 3
},
"3": {
"no": 4
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我的预期结果
{
{
"no": 3
},
{
"no": 4
}
}
Run Code Online (Sandbox Code Playgroud)
预期的结果是没有索引,但是如何在没有 foreach 或循环的情况下进行制作,我担心如果使用循环会花费时间字母
我花了很多时间来解决,但我的 ssh 仍在运行
wahyono17@komputer2:~$ ps -e |grep [s]sh-agent
2311 ? 00:00:00 ssh-agent
2343 ? 00:00:00 ssh-agent
Run Code Online (Sandbox Code Playgroud)
但是当我添加 ssh 时出现错误
wahyono17@komputer2:~$ sudo ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
Run Code Online (Sandbox Code Playgroud)
当我尝试下一步时出现错误
wahyono17@komputer2:~$ sudo ssh-add -L
Could not open a connection to your authentication agent
Run Code Online (Sandbox Code Playgroud)
我尝试直接检查 github 连接,但出现错误
wahyono17@komputer2:~$ sudo ssh -T git@github.com
Permission denied (publickey)
Run Code Online (Sandbox Code Playgroud)
public已经在github中,我已经将公钥保存到github中,但仍然有错误
感谢帮助