I'd like to put each file name in $xsl_dir_path (absolute path) in select element. I've tried this:
$files = glob($xsl_dir_path . "/*.xsl");
array_walk($files, 'basename');
but it's not working at all, i can still see the full names of the files. I know i can apply basename when lopping through $files and build the option elements, but i'd like to do it before any html output.
array_walk is useful when your callback function accepts a reference or when you use user-defined callback functions. In this case, the basename argument is not a reference.
What you want is array_map:
$files = glob($xsl_dir_path . "/*.xsl");
$files = array_map('basename', $files);
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