私のコードの何が問題なのかについてのアイデアが不足しています。この特定のクラスは配列を受け入れ、それを別の配列と照合して共通の値を取得します。次に、 final_post_vars_keys() 関数を介して共通の値へのアクセスを提供します。しかし、コードを実行するたびに(タイトルに)エラーが発生します。
<?php
class PostVarsKeys {
private $general_keys = array("name", "email", "custom phone" , "lastname" , "firstname", "fname", "lname", "phone" , "emailaddress" ,
"phonenumber");
private $post_vars_keys = array();
public function __construct($post_keys){
$counter=0;
foreach($post_keys as $key => $value):
$this->post_vars_keys[$counter++] = $key;
endforeach;
}
public function final_post_vars_keys(){
return $final_keys = array_intersect($this->general_keys, $this->post_vars_keys);
}
}