In php
Sprache, haben wir etwas Praktisches zu tun Aufgabe als das folgende Snippet?
$acceptableInputs = [];
foreach ($this->fields as $field) {
$value = array_key_exists($field, $formInputs)
? $formInputs[$field]
: '';
$acceptableInputs[$field] = $value;
}
3 Zeilen sind ziemlich * praktisch * denke ich. – Rizier123
Mögliche Duplikate von [Entfernen Sie alle Array-Elemente außer was ich will?] (Http://stackoverflow.com/questions/10122801/remove-all-array-elements-except-what-i-want) –