To the following code
function register(): int
{
$filter = array(
'email' => FILTER_VALIDATE_EMAIL,
'password' => array(
'filter' => FILTER_VALIDATE_REGEXP,
'options' => array('regexp' => '/^(?=\S*\d)(?=\S*[a-zA-Z])\S{8,}$/')
)
);
$filter['password_bis'] = &$filter['password'];
$user_data = filter_input_array(INPUT_POST, $filter, FILTER_NULL_ON_FAILURE);
var_dump($user_data);
return 1;
}
I submitted POST data
array('email' => 'my@email.net', 'password' => 'wrong')
The email filter works as expected. But, not the password one.
array(2) {
["email"]=>
string(12) "my@email.net"
["password"]=>
string(5) "wrong"
}
Any ideas of what I missed?
EDIT:
I'm using php7. Even the function filter_var_array(array('email' => 'test@ok.com', 'password' => 'wrong'), $filter, FILTER_NULL_ON_FAILURE)
doesn't work. But, with php5 it's ok. Perhaps it's a bug from php7?