Display Image based on root directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cletus_snow
Forum Newbie
Posts: 1
Joined: Mon Sep 11, 2006 1:13 pm

Display Image based on root directory

Post by cletus_snow »

Hello-
I have a script that will display a specific image image based on what the directory name is.
What I need is to have the image display in directories contained in the root directory such as "Perkins", that all pages in all folders under Perkins will display that image.Here is what I have so far:

Code: Select all

<?php


function this_folder_name($path){
if (!$path){$path=$_SERVER['PHP_SELF'];}
$current_directory = dirname($path);
$current_directory = str_replace('\\','/',$current_directory);
$current_directory = explode('/',$current_directory);
$current_directory = end($current_directory);
return $current_directory;
}
#print this_folder_name();

if (this_folder_name() =='perkins')
{
$display = "<img src=\"../images/cte_header12.jpg\" alt=\"Perkins Header\">";

}
elseif (this_folder_name() =='aboutus')
{
$display = "<img src=\"../images/cte_header20.jpg\" alt=\"About Us Header\" >";

}

elseif (empty($current_directory))
{
$display = "<img src=\"../images/cte_header10.jpg\" alt=\"CTE Header Image\" >";

}
echo $display;
?>

Any help would be awesome.

Thanks-
Cletus
Post Reply