Skip to content

修复only和except方法丢失数组中的null值#139

Open
luoyue712 wants to merge 1 commit into
walkor:masterfrom
luoyue712:patch-3
Open

修复only和except方法丢失数组中的null值#139
luoyue712 wants to merge 1 commit into
walkor:masterfrom
luoyue712:patch-3

Conversation

@luoyue712
Copy link
Copy Markdown
Contributor

以下示例丢失了key为e的元素

$all = [
    'a' => 'a',
    'b' => true,
    'c' => false,
    'd' => '',
    'e' => null,
    'f' => 0,
    'g' => 1,
];
$keys = ['a', 'b', 'c', 'd', 'e', 'f'];
$result = [];
foreach ($keys as $key) {
    if (isset($all[$key])) {
        $result[$key] = $all[$key];
    }
}
print_r($result);
// 错误返回
//Array
//(
//    [a] => a
//    [b] => 1
//    [c] => 
//    [d] => 
//    [f] => 0
//)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant