This one for php:
if ($handle = opendir('./')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && strtolower(substr($entry, strrpos($entry, '.') + 1)) == 'pdf') {
$str = $str.' '.$entry; }}}
exec( '"C:\Program Files\gs\gs9.53.3\bin\gswin64.exe" -dNOPAUSE -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOUTPUTFILE=combine.pdf -dBATCH '.$str.'');