我有超过1k个这种格式的数组。
[0] => stdClass Object (
[order_date] => 2017-11-23
[status] => Shipped
[destination] => "Chicago"
[car_make] => YYY
[customer] => "Vic" )
[1] => stdClass Object (
[order_date] => 2017-11-24
[status] => Received
[destination] => "New York"
[car_make] => ZZZ
[customer] => "Admin" )
[2] => stdClass Object (
[order_date] => 2017-11-23
[status] => Shipped
[destination] => "Detroit"
[car_make] => XXX
[customer] => "Vic" )
[3] => stdClass Object (
[order_date] => 2017-11-13
[status] => Complete
[destination] => "LA"
[car_make] => WWW
[customer] => "John" )
我想使用多个键过滤整个数据。
我用过
array_filter
在闭包中,它只基于一个键完美地过滤数据。
function cc_filter_car_data( $data )
{
return function( $key,$value ) use( $data )
{
return array_filter( $data, function( $data_1 ) use( $key,$value )
{
return $data_1->$key === $value;
});
};
}
上述示例
cc_filter_car_data()
我可以返回所有数组,其中
customer = Vic
(仅过滤一个键)。
where status=shipped
或
客户=Vic
或
car_make = ZZZ
. (多个不同的键)
我的问题是:
我如何解决这个问题?感谢您的帮助。
其他:
每个阵列总共有
13 keys
可以进行过滤。
car_make
然后根据
car_model
等等
请参阅一个好的jquery示例
here
我正在做服务器端处理