Charlie8776
01-09-2012, 02:07 AM
Goal: All php files are numbered by integer (e.g. 1.php, 2.php, 3.php, etc.) When users access index.php?1, then 1.php is included (and so forth for any integer). How can I simplify the code below so I don't have to type out each number?
Bonus: All the php files are stored in index/include folder. How can I specify the default (calling index.php without a variable) to include the top ten php files in that folder (e.g. 900.php through 910.php)?
<?PHP
if(isset($_GET['1'])){
include('index/include/1.php');
} else if(isset($_GET['2'])){
include('index/include/2.php');
} else if(isset($_GET['3'])){
include('index/include/3.php');
} else if(isset($_GET['4'])){
include('index/include/4.php');
} else {
include('index/include/1.php');
}
?>
Bonus: All the php files are stored in index/include folder. How can I specify the default (calling index.php without a variable) to include the top ten php files in that folder (e.g. 900.php through 910.php)?
<?PHP
if(isset($_GET['1'])){
include('index/include/1.php');
} else if(isset($_GET['2'])){
include('index/include/2.php');
} else if(isset($_GET['3'])){
include('index/include/3.php');
} else if(isset($_GET['4'])){
include('index/include/4.php');
} else {
include('index/include/1.php');
}
?>