Happy new years folks,
I have a problem. I'm trying to set up a webpage using php to handle much of my link interactions. Now, I have several categories, and each will have its own set of links.
So, let us say that I want to be able to pick different links for each color, and each color below will have several possible subcategories or objects. I would far rather use wildcards to specify each list than have to put an incredibly long if/elseif statement.
[CODE=php]
<?php
$pass = array('redtruck ','redhouse','r edhat','redshir t','redhair','r edbicycle','red wagon','greenwa gon','greentruc k','greenshirt' ,'greenlawn','g reenhouse','gre enhat','greenai rplane','bluesk y','bluejeans', 'bluebell','blu eeyes','bluesgu itar',);
if (in_array($_GET['id'], $pass)) {
if ($_GET['id'] == 'red' . '*'') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/redlinks.php'); }
elseif ($_GET['id'] == 'green' . '^') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/greenlinks.php' ); }
elseif ($_GET['id'] == 'blue' , '*') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/bluelinks.php') ; }
else {
header("HTTP/1.0 404 Not Found");
include ($_SERVER['DOCUMENT_ROOT'].'/includes/error.php');
}
?>
[/CODE]
Is there a way to do this, without having to write an incredibly long if/elseif statement to check for every single possible 'red*' 'green*' and 'blue*' posibilities?
I have a problem. I'm trying to set up a webpage using php to handle much of my link interactions. Now, I have several categories, and each will have its own set of links.
So, let us say that I want to be able to pick different links for each color, and each color below will have several possible subcategories or objects. I would far rather use wildcards to specify each list than have to put an incredibly long if/elseif statement.
[CODE=php]
<?php
$pass = array('redtruck ','redhouse','r edhat','redshir t','redhair','r edbicycle','red wagon','greenwa gon','greentruc k','greenshirt' ,'greenlawn','g reenhouse','gre enhat','greenai rplane','bluesk y','bluejeans', 'bluebell','blu eeyes','bluesgu itar',);
if (in_array($_GET['id'], $pass)) {
if ($_GET['id'] == 'red' . '*'') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/redlinks.php'); }
elseif ($_GET['id'] == 'green' . '^') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/greenlinks.php' ); }
elseif ($_GET['id'] == 'blue' , '*') {
include ($_SERVER['DOCUMENT_ROOT'].'/includes/bluelinks.php') ; }
else {
header("HTTP/1.0 404 Not Found");
include ($_SERVER['DOCUMENT_ROOT'].'/includes/error.php');
}
?>
[/CODE]
Is there a way to do this, without having to write an incredibly long if/elseif statement to check for every single possible 'red*' 'green*' and 'blue*' posibilities?
Comment