如何在多个数组中搜索。我正在为datatable创建自定义搜索功能。我该怎么做呢?我被困住了,我怎么才能在数组中搜索和查找并返回数组呢?
$records = Array
(
[0] => Array
(
[0] => 28
[1] => http://198.58.98.34:4600/uploads/item/priority_images-1519195620005Item1.png
[2] => Currency
[3] => Demo1
[4] => Hello
[5] => 980
[6] => 2018-02-21T06:47:15.264Z
)
[1] => Array
(
[0] => 27
[1] => http://198.58.98.34:4600/uploads/item/1519120091372-filewinter_is_here_game_of_thrones_hd-1920x1080.jpg
[2] => coins212
[3] => Demo2
[4] => Hello1
[5] => 54564
[6] => 2018-02-21T06:38:04.053Z
)
);
$search = $request['search']['value'];我试着使用array_column,但它不起作用。如何搜索和返回搜索到的数据。?
发布于 2018-02-21 15:32:41
你可以使用laravel中的collect函数来制作collection,也可以使用where函数来过滤
$collect = collect($records);
$search = $collect->where('search_column','value'); 在您的示例中,您可以使用列号作为。ie第3列,关键字为2
$search = $collect->where('2','Currency');将给出在第三列中有Currency的数组。使用key 2
请检查采集here的所有可用方法
https://stackoverflow.com/questions/48900214
复制相似问题