Database.php array_filter not working?

While editing database.php I found that the following was present there. and when I added a new option to this, I noticed that it wasn’t working.

'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],

However, when I removed the array_filter, and directly added the options as a raw array, it was working.

'options' => array(
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => env('MYSQL_ATTR_SSL_VERIFY'),
PDO::MYSQL_ATTR_SSL_CA => '/some/path/cert/database.crt.pem',
),

Any idea why this may be the case?

PS: I have checked the pdo_mysql is returning true, so something has to do with array_filter. so I am wondering, what is its need here?

@tasaduqbahl ,

Does ‘MYSQL_ATTR_SSL_CA’ was set in .env ?

Yes, it was set in env, and also ran following after setting it.

php artisan config:cache