I need to check if the folder name is equal to for example, "Food", then do something, else don't do anything.
How do I do that? Thank you very much.
Longhaired Genius
10:58 pm on Jun 6, 2005 (gmt 0)
$string = $_SERVER['PHP_SELF']; if (preg_match("/\/food/", "$string")) { do something; }
yellow_nemo
11:21 pm on Jun 6, 2005 (gmt 0)
can you explain to me what "/\/" means in front of "Food"? Thanks!
Longhaired Genius
11:28 pm on Jun 6, 2005 (gmt 0)
The first / indicates the start of the regular-expression. The following \/ is the escaped forward-slash in the URL. The final / indicates the end of the regular-expression. You could have "/\/food\//" for completeness if the directory name is "food". You include the slashes so you don't match something inadvertently like "myfavouritefood.php".