On Thursday, January 13, 2011 12:45:30 pm Nathan Rixham wrote: > David McGlone wrote: > > Hi everyone, > > > > I think the subject is right, or somewhere close. Anyway I am trying to > > perform a little trickery here with links. In the following code you can > > see where I am trying to replace the link on the current page so it's > > not a link when on that page. I think I got the general idea of what I > > need to do as you can see in the code I just don't know how to > > accomplish it, if it's possible. > > > > > > $categorys = array('home', 'services', 'gallery', 'about_us', > > 'contact_us', 'testimonials'); > > foreach($categorys as $category){ > > $deadlink = $_GET['page']; > > > > if ($deadlink == 'page') { > > for a short answer, all you need to do is change the above line to: > > if($deadlink == $category) > > and as a slightly colourful variant: > > $categorys = array('home', 'services', 'gallery', 'about_us', > 'contact_us', 'testimonials'); > foreach($categorys as $category){ > $temp = str_replace("_", " ", $category); > $_GET['page'] != $category && $temp = '<a href="index.php?page='. > $category .'">'.$replace.'</a>'; > echo "<li>{$temp}</li>" . PHP_EOL; > } Nathan, thanks for showing me this. I understand the code, except I don't understand how you got by without using a conditional (if/else). If it were me, I would have written it like: $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', 'testimonials'); foreach($categorys as $category){ $temp = str_replace("_", " ", $category); if( $_GET['page'] != $category && $temp = '<a href="index.php?page='. $category .'">') { echo <a href="index.php?page='.$category . '">'.$replace.'</a>'; } else { echo "<li>{$temp}</li>" ; } I haven't tested this code, but this is how I would have thought about going about it. My questions are, is this wrong? is it amaturish? -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php