Simple PHP question:
Why does this work,
$exclude_exts = array('js', 'css',);
$filename = "test.css";
$ext = explode('.',$filename);
$is_excluded = in_array(strtolower(array_pop($ext)), $exclude_exts);
but this doesn't.
$exclude_exts = array('js', 'css',);
$filename = "test.css";
$is_excluded = in_array(strtolower(array_pop(explode('.',$filename))), $exclude_exts);
Edit: Both used to work in a previous version of PHP (I forgot which version).
Because array_pop requires a reference, since it alters the array in place.
When you pass the return value of explode
there is no variable there to reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With