index <=> $b->index; //For some reason, PHP8 requires the spaceship operator (<=>) //instead of a greater than symbol. } function gen_nav_element($page){ $iframe = false; //By default, echo the contents of a file instead of embedding it in an iframe. if(isset($page->file)){ $href = "index.php?page=".$page->query_value; $target = "_self"; //If the page is associated with a file, then point the navibar href to the file's query value. $iframe = (isset($page->iframe)) ? true : false; //If the page has the iframe attribute, then keep track of that. } elseif(isset($page->link)) { $href = $page->link; $target = "_blank"; //If instead the page is associated with an external link, then point the navibar href there and make it open in a new window. } echo ""; } $page_array = get_object_vars($pages); //Convert $pages from object to an associative array of [key=>val, key=>val] //where the keys are the names of the page objects from the JSON file and the //vals are the page objects themselves. usort($page_array,"page_comparator"); //Sort the pages in order of increasing "index" value. foreach($page_array as $key=>$p){ if($p->index>-1){ gen_nav_element($p); //Pages with indices less than 0 are hidden from the navibar. } } ?>