'Page One', 'two' => 'Page Two', 'three' => 'Page Three', ); */ function displayWizard($pages) { $keys = array_keys($pages); if (isset($_REQUEST['page'])) { // navigate to another page in the wizard $page = $_REQUEST['page']; $action = $_REQUEST['action']; // Figure out the function for this page. Search the keys. $k = array_search($page, $keys); if ($k === FALSE) { msg('E',"Page $page not found in the wizard."); exit; } if ($action == 'back') { $k--; if ($k < 0) { msg('E',"Can't go backward past the 1st page ($page)."); exit; } } elseif ($action == 'next') { $k++; if ($k >= count($pages)) { $k = 0; } // this was the Finish button - go back to the beginning } elseif ($action == 'cancel') { $k = 0; //todo: unset all the _SESSION variables } // Run the function for this page $keys[$k](); configureButtons($k, $pages); } else { // initial display of the wizard - show the 1st page echo "
"; $text = array(); foreach ($keys as $k => $key) { $text[] = "$pages[$key]"; } echo implode(' -> ', $text); echo "
\n"; echo "