Php 使用特定数组元素处理数组值

Php 使用特定数组元素处理数组值,php,arrays,sorting,arraylist,multidimensional-array,Php,Arrays,Sorting,Arraylist,Multidimensional Array,我有这样一个数组值。我尝试了数组搜索,但没有用。 我只想筛选具有状态值的数组值 输出 预期产量 如果预期的输出有正确的数字序列,我会更高兴。在上述情况下,有两个数组的数组编号分别为[1]和[3]。如果可能,我需要将其设置为[1]和[2] 任何帮助都是非常有用的 谢谢, Kimz你可以这样做 foreach($my_array as $arr) { if(isset($arr['status']) && $arr['status'] != '') { $te

我有这样一个数组值。我尝试了数组搜索,但没有用。 我只想筛选具有状态值的数组值

输出 预期产量 如果预期的输出有正确的数字序列,我会更高兴。在上述情况下,有两个数组的数组编号分别为[1]和[3]。如果可能,我需要将其设置为[1]和[2]

任何帮助都是非常有用的

谢谢, Kimz

你可以这样做

foreach($my_array as $arr) {
    if(isset($arr['status']) && $arr['status'] != '') {
        $temp_array[] = $arr;
    }
}
print_r($temp_array);
你可以用


乔塔姆-有人投了反对票。不知道为什么。你能投票表决我的问题吗;请我已经记下了你的答案;
Array
    (
    [1] => Array
    (
    [author] => Author1
    [book] => Book1
    [status] => 1
    )

    [3] => Array
    (
    [author] => Author3
    [book] => Book3
    [status] => 1
    )
    )
foreach($my_array as $arr) {
    if(isset($arr['status']) && $arr['status'] != '') {
        $temp_array[] = $arr;
    }
}
print_r($temp_array);
$array = array(['status' => 1], [], ['status' => 1]);

$result = array_filter($array, function($item)
    {
    return !empty($item['status']);
    });

var_dump($result);