I'm very very new to php and i've been using this code from a tut i found online for one of my pages. I have a feeling there is a very simple solution for what I want to do. The code explains itself so i'll get right into it...
<?php
// 1. Define an array of allowed $_GET values:
$pass = array('p01s01','p02s01','p03s01','p04s01','p06s01','p07s01','p10s01','p12s01','p14s01');
// 2. If the page is allowed, include it:
if (in_array($_GET['id'], $pass)) {
include ('includes/AprilStories/' . $_GET['id'] . '.php');
}
// 3. If there is no $_GET['id'] defined, then serve the homepage:
elseif (!isset($_GET['id'])) {
include ("includes/blank.php");
}
// 4. If the page is not allowed, send them to an error page:
else {
// This sends the 404 header:
header("HTTP/1.0 404 Not Found");
// This includes the error page:
include ("includes/error.php");
}
?>
I simply want to use regex for the very first part of the code where it defines an array of allowed $_GET values. Right now i have every page 'id' listed. I'd like to simplify that with regex so it will match "p[:digit:]{2}s[:digit:]{2}"
I've tried everything and still cant get it to work....i think im trying to put the ereg in the wrong place.
also here is the url for the page im trying to use regex on... www.obsrep.com/businessjournal/stories.php
additionally i was trying to put the ereg() in the array()....not sure if that was right
thanks!