Php 从两个值之间的多维数组中获取数组

Php 从两个值之间的多维数组中获取数组,php,Php,我有这样一个数组: Array ( [0] => Array ( [date] => 1523752578 [weight1] => 1890 [weight2] => 1760 ) [1] => Array ( [date] => 1523756192 [weight1] =

我有这样一个数组:

Array
(
    [0] => Array
        (
            [date] => 1523752578
            [weight1] => 1890
            [weight2] => 1760
        )

    [1] => Array
        (
            [date] => 1523756192
            [weight1] => 1890
            [weight2] => 1760
        )

    [2] => Array
        (
            [date] => 1523759807
            [weight1] => 1890
            [weight2] => 1760
        )

    [3] => Array
        (
            [date] => 1523763423
            [weight1] => 1890
            [weight2] => 1760
        )
)
如何从数组中获取两个[date]值之间的数组

例如,第一个值是
1523756192
,第二个值是
1523763423
,它应该返回一个数组,该数组包含
[1]
[2]
[3]
,但不包含
[0]
,并且该数组仍然应该包含
[weight1]
[weight2]


“to”和“from”值来自两个输入,其中用户选择两个日期。然后,我将从两个日期之间的父数组中选择所有子数组。

我想您正在寻找

函数filterbydate($arr、$lowdate、$highdate){
返回数组过滤器($arr,函数($val)使用($lowdate,$highdate){
返回$val['date']>=$lowdate&$val['date']1523752578,
“权重1”=>1890,
“权重2”=>1760],
['date'=>1523756192,
“权重1”=>1890,
“权重2”=>1760],
['date'=>1523759807,
“权重1”=>1890,
“权重2”=>1760],
['date'=>1523763423,
“权重1”=>1890,
“权重2”=>1760]];
var_dump(filterbydate($arr,1523756192,1523763423));
请注意,这将保留索引值,因此结果的索引将为1、2和3。如果要对它们重新编号,可以在结果数组上使用-因此,将filterbydate内部替换为:

    return array_values(
            array_filter($arr, function($val) use ($lowdate, $highdate) {
                 return $val['date'] >= $lowdate && $val['date'] <= $highdate;
               }));
返回数组_值(
数组过滤器($arr,函数($val)使用($lowdate,$highdate){

返回$val['date']>=$lowdate&&$val['date']你怎么知道第二个元素是第一个值,第四个元素是第二个值?请分享你的尝试?父数组要长得多,但我需要两个输入,用户可以选择两个日期,然后我会选择两个日期之间的所有子数组。你对此有sql查询吗?这不是sql,而是CSV我已将其转换为PHP ArrayFect的文件。谢谢!欢迎!我在您回复的同时编辑了它,因此希望确保您看到更新的版本。
    return array_values(
            array_filter($arr, function($val) use ($lowdate, $highdate) {
                 return $val['date'] >= $lowdate && $val['date'] <= $highdate;
               }));