1
PHP:PHP,Laravel - 通配符鍵搜索數組並返回數組結果
$getallvalues
讓我從會話數組:
array:7 [▼
"_token" => "ZCP63uasUQHl948oVVDG7ZO4x33"
"_previous" => array:1 [▶]
"flash" => array:2 [▶]
"key1" => "1"
"key2" => "2"
"id-2" => "2"
"id-3" => "3"
]
如何獲取一個新的陣列通配符鍵「 ID-」給我的結果:
array:2 [▼
"id-2" => "2"
"id-3" => "3"
]
我tryed一些PHP的方法,如:array_values,in_array等,但沒什麼克按我的預期工作。
看到這個[https://glot.io/snippets/eew9bqe5hb](https://glot.io/snippets/eew9bqe5hb) –
@GarvitMangal您可以使用'array_intersect_key',而不是在foreach提高你的答案循環 – Scopey
@Scopey謝謝你指着我 –