'Previous', 1 => 'Home', 2 => 'About myself', 3 => 'What I\'ve done so far', 4 => 'Who I would like to be', 5 => 'Contact me via webform' ]; if ( ! isset ( $_POST ['section'] ) || ! in_array ( $_POST ['section'], array_keys( $sections ) ) ) { $section_title = 'Home'; } else { $section = $_POST ['section']; if ( $section == 0 ) { if ( isset ( $_SESSION [ 'section' ] ) ) { $section = $_SESSION [ 'section' ]; } else { $section = 1; } } $_SESSION [ 'section' ] = $section; $section_title = $sections [ $section ]; $sections_content = [ 1 => file_get_contents ( 'tmpl/home.phtml' ), 2 => file_get_contents ( 'tmpl/description.phtml' ), 3 => file_get_contents ( 'tmpl/projects.phtml' ), 4 => file_get_contents ( 'tmpl/ideas.phtml' ), 5 => file_get_contents ( 'tmpl/contact-form.phtml' ), ]; $arr_res = [ 'status' => 200, 'pageTitle' => $section_title, 'html' => $sections_content [ $section ] ]; $res = json_encode($arr_res); header('Content-Type: application/json'); echo $res; exit; } ?>