如何区分 Laravel 中的默认数组?
How to diff default array in Laravel?
我有简单的数组:
$array = array(1,5,7,9,3,0);
并从数据库收集:
$collection = DB::table('numbers')->pluck('number');
Collection {#194 ▼
#items: array:12 [▼
0 => "1"
1 => "2"
2 => "3"
3 => "4"
4 => "5"
5 => "6"
]
}
如何在 Laravel 中区分这个数组?
以及如何在 laravel:
中区分默认数组 ($array) 另一个数组
$another_array = DB::select("SELECT number FROM numbers");
array:12 [▼
0 => {#194 ▼
+"number": "0"
}
1 => {#207 ▼
+"number": "-1"
}
2 => {#209 ▼
+"number": "1"
}
3 => {#206 ▼
+"number": "-2"
}
]
尝试:
$collection = DB::table('numbers')->pluck('number')->toArray();
$diff = array_diff($collection, $array);
我有简单的数组:
$array = array(1,5,7,9,3,0);
并从数据库收集:
$collection = DB::table('numbers')->pluck('number');
Collection {#194 ▼
#items: array:12 [▼
0 => "1"
1 => "2"
2 => "3"
3 => "4"
4 => "5"
5 => "6"
]
}
如何在 Laravel 中区分这个数组? 以及如何在 laravel:
中区分默认数组 ($array) 另一个数组$another_array = DB::select("SELECT number FROM numbers");
array:12 [▼
0 => {#194 ▼
+"number": "0"
}
1 => {#207 ▼
+"number": "-1"
}
2 => {#209 ▼
+"number": "1"
}
3 => {#206 ▼
+"number": "-2"
}
]
尝试:
$collection = DB::table('numbers')->pluck('number')->toArray();
$diff = array_diff($collection, $array);