I want to store a function in an associative array but PHP throws this error:
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in C:\Program Files\wamp\www.... on line 12
Code is here: You may also get idea what I'm trying to do.
private $rules = array(
"required" => array(
"message" => "This field is required",
"rule" => function($value) {
return isset($value) && !empty($value);
}
)
);
There is no answer there in those questions mentioned by moderator but only is information. I have edited the question and it fully qualifies for an answer now. The comments which had solution to this problem was deleted by moderator although some of them needed to be.