Answer the question
In order to leave comments, you need to log in
Have I built the Allowed class correctly?
There is a "class" Allowed that compares the keys of arrays ( 1 - an existing array (allowed fields) and 2 - an array that came (POST request))
here is its brief implementation:
$one = array('one','two','three'); //существующий массив эти поля разрешены
$arr = array('one'=>1,'two'=>2,'three'=>3,'four'=>4); //пришел POST
$two = array_keys($arr); // заберу ключи у массива который пришел
$three = array_intersect($one,$two); // Сравню массивы
$out = array(); // сюда запишем совпадения
foreach($arr as $key => $value){
if(in_array($key, $three)){
$out[$key] = $value;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question