1 回答

TA貢獻(xiàn)1966條經(jīng)驗(yàn) 獲得超4個贊
<?php
$array = [
['one' => 'aa', 'two' => 'qq'],
['one' => 'bb', 'two' => 'qq'],
['one' => 'aa', 'two' => 'qq'],
['one' => 'bb', 'two' => 'qq'],
['one' => 'aa', 'two' => 'qq'],
];
$keys = array_keys(array_column($array, 'one'), 'aa');
$array2 = array_filter($array, static function($key) use ($keys) {
return in_array($key, $keys, true);
}, ARRAY_FILTER_USE_KEY);
$keys2 = array_keys(array_combine(array_keys($array2), array_column($array2, 'two')), 'qq', true);
echo '<pre>';
var_dump($array, $keys, $array2, $keys2);
echo '</pre>';
- 1 回答
- 0 關(guān)注
- 121 瀏覽
添加回答
舉報