Mercurial > hg > webaudioevaluationtool
diff php/get_tests.php @ 2283:169f08dc9634
Fix for #25, PHP uses the array() function rather than the [] initialiser (only supported if PHP >= 5.4)
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 22 Apr 2016 09:34:34 +0100 |
parents | 760719986df3 |
children | d26623bd65e0 |
line wrap: on
line diff
--- a/php/get_tests.php Wed Apr 20 21:41:49 2016 +0200 +++ b/php/get_tests.php Fri Apr 22 09:34:34 2016 +0100 @@ -5,38 +5,10 @@ This script returns the XML test names available, plus the number of tests */ -//http://stackoverflow.com/questions/4444475/transfrom-relative-path-into-absolute-url-using-php -function rel2abs($rel, $base) -{ - /* return if already absolute URL */ - if (parse_url($rel, PHP_URL_SCHEME) != '' || substr($rel, 0, 2) == '//') return $rel; - - /* queries and anchors */ - if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel; - - /* parse base URL and convert to local variables: - $scheme, $host, $path */ - extract(parse_url($base)); - - /* remove non-directory element from path */ - $path = preg_replace('#/[^/]*$#', '', $path); - - /* destroy path if relative url points to root */ - if ($rel[0] == '/') $path = ''; - - /* dirty absolute URL */ - $abs = "$host$path/$rel"; - - /* replace '//' or '/./' or '/foo/../' with '/' */ - $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); - for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} - - /* absolute URL is ready! */ - return $scheme.'://'.$abs; -} +include "rel2abs.php"; // XML Saves location - assumes it will be saves/ -$data = []; +$data = array(); $saves = glob("../saves/*.xml"); if (is_array($saves)) { @@ -52,7 +24,7 @@ array_push($data[$testName],$filename); } else { // Key does not exist - $data[$testName] = [$filename]; + $data[$testName] = array($filename); } } }