comparison php/pool.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 30c012132427
children d26623bd65e0
comparison
equal deleted inserted replaced
2281:185232d01324 2283:169f08dc9634
15 // MODIFY THE FOLLOWING LINE TO POINT TO YOUR TEST FILE 15 // MODIFY THE FOLLOWING LINE TO POINT TO YOUR TEST FILE
16 $master_file = "../tests/pool.xml"; 16 $master_file = "../tests/pool.xml";
17 // Note this is relative to the PHP location 17 // Note this is relative to the PHP location
18 18
19 // First set up the store with all the test page key nodes 19 // First set up the store with all the test page key nodes
20 $pages = []; 20 $pages = array();
21 $master_xml = simplexml_load_string(file_get_contents($master_file, FILE_TEXT)); 21 $master_xml = simplexml_load_string(file_get_contents($master_file, FILE_TEXT));
22 if ($master_xml) { 22 if ($master_xml) {
23 if (!isset($master_xml->setup["poolSize"])) 23 if (!isset($master_xml->setup["poolSize"]))
24 { 24 {
25 echo file_get_contents($master_file, FILE_TEXT); 25 echo file_get_contents($master_file, FILE_TEXT);
70 // Copy over the <setup> node 70 // Copy over the <setup> node
71 $dom_setup = $new_doc->importNode(dom_import_simplexml($master_xml->setup),true); 71 $dom_setup = $new_doc->importNode(dom_import_simplexml($master_xml->setup),true);
72 $root->appendChild($dom_setup); 72 $root->appendChild($dom_setup);
73 73
74 // We must now extract the number which have been performed the least 74 // We must now extract the number which have been performed the least
75 $rot_pages = []; 75 $rot_pages = array();
76 foreach($pages as $key => $var) 76 foreach($pages as $key => $var)
77 if(array_key_exists($var,$rot_pages)) { 77 if(array_key_exists($var,$rot_pages)) {
78 array_push($rot_pages[$var],$key); 78 array_push($rot_pages[$var],$key);
79 } else { 79 } else {
80 $rot_pages[$var] = [$key]; 80 $rot_pages[$var] = array($key);
81 } 81 }
82 ksort($rot_pages); 82 ksort($rot_pages);
83 $Keys = array_keys($rot_pages); 83 $Keys = array_keys($rot_pages);
84 84
85 // Pages are grouped into an array based on the number of page initiations ($rot_pages) 85 // Pages are grouped into an array based on the number of page initiations ($rot_pages)