note 83686 modified in function.in-array by mgf

From: Date: Mon, 09 Jun 2008 11:04:20 +0000
Subject: note 83686 modified in function.in-array by mgf
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140264@lists.php.net to get a copy of this message
<?php $pages = array('help', 'main', 'contact'); function isDefined($page) { return in_array($page, $pages, true); } $act = $_GET['act']; function loadPage() { if(isDefined($act)) include $act . '.php'; else include 'index.php'; } loadPage(); ?> Just wrote it so I could load pages, and if they're not defined in the array, I can load the default page. --was-- <?php $pages = array('help', 'main', 'contact'); function isDefined($page) { if(in_array($page, $pages, true) return true; else return false; } $act = $_GET['act']; function loadPage() { if(isDefined($act)) include $act . '.php'; else include 'index.php'; } loadPage(); ?> Just wrote it so I could load pages, and if they're not defined in the array, I can load the default page. http://php.net/manual/en/function.in-array.php

« previous php.notes (#140264) next »