RE: [PHP] must be a better way

From: Date: Wed, 18 Oct 2000 02:54:41 +0000
Subject: RE: [PHP] must be a better way
Groups: php.general 
Request: Send a blank email to php-general+get-20763@lists.php.net to get a copy of this message
a better way would be this: explode your$SCRIPT_NAME by slashes, $this_file = $SCRIPT_NAME; $dir = explode( '/', $this_file ); then $dir[0] is the main directory from root, $dir[1] is the second and so on.. for instance if this is your script name: /main/200/10/18/hello_world.php then the array would look like this: $dir[0] = 'main'; $dir[1] = '2000'; $dir[2] = '10'; $dir[3] = '18'; $dir[4] = 'hello_world.php'; so what you do then is this: checkj for dot in the last item of $dir ( $last_item = $dir[count($dir)-1]; ) with strstr, if true assign that $last_item to a $file, then go to check the first $dir, if($dir[0] == 'main) { then here you will know that the next three folders are equivalent to a time value, so you can sompose a time in mysql format to later limit your searches in the database. } then $file is your file, and so on ... your inventions here: ... This is what I use for a very large project. Cheers! -----Original Message----- From: Jerry Lake [mailto:jerryl@europa.com] Sent: Wednesday, October 18, 2000 7:14 AM To: php-general@lists.php.net Subject: [PHP] must be a better way I know there is a better way to express what I have here I just can't think of it today... if (ereg ("services", $PHP_SELF)) { $header = "Available Services"; } else { $header = "Welcome"; } if (ereg ("about", $PHP_SELF)) { $header = "About the Company"; } else { $header = "Welcome"; } would it be like this, maybe? if (ereg ("something", $string)) { $something = "this"; } else { $something = "that"; } elseif (ereg ("somethingelse", $string)) { $something = "this"; } additionally is there a way to declare 2+ variables for one true outcome i.e. if (true) { $item = "something"&& $item2 = "somethingelse"; } Jerry Lake - jerryl@europa.com Web Designer Europa Communications - http://www.europa.com Pacifier Online - http://www.pacifier.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#20763) next »