php glob() if empty returns array on windows, none on linux

apache, glob, php

Solution

From http://php.net/manual/en/function.glob.php:

Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error.

Check if `glob($path_ . '*.js') === FALSE` on linux. In this case, there is probably a permission error or something like this. It should be an empty array if there is no error, as the documentation suggests.

Also check for the case in your files/directory. Windows is case insensitive, that could explain a difference between windows and linux.

Problem

At the moment I have: ``` $files = array_merge( glob($path_ . '*.js'), glob($path_ . '*.css')); ``` If the directories are empty on windows it returns an empty array. If they are empty on linux nothing is returned. This produces this error on linux: Warning: array_merge() [function.array-merge]: Argument #1 is not an array - Windows: Apache:2.2.21 PHP:5.3.10 - Linux/Debian: Apache:2.2.16 PHP:5.3.10 After some further research and testing I found that it is a bug in PHP: https://bugs.php.net/bug.php?id=53460

Original source