Forum Moderators: coopster

Message Too Old, No Replies

Weirdish php question...

hard to explain

         

phidentity

6:49 pm on Jul 18, 2004 (gmt 0)

10+ Year Member




if( file_exists( $row["cocktailname"].".php" ) ) {
echo("<a href=\"{$row["cocktailname"]}.php\">{$row["cocktailname"]}</a><br>");
} else {
echo($row["cocktailname"]."<br>");
}
}

The code above checks if 'cocktailname.php exists, and creates a link to it if it does, if not, just plain text is printed.

How can I make it so that, if it exists, it creates a link to, for example

"long-island-iced-tea.php" instead of "long island iced tea.php"

I don't like spaces in my links you see...

Thanks a bunch guys :)

Jon

dmorison

6:55 pm on Jul 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use str_replace() [uk2.php.net] on $row["cocktailname"] to replace " " with "-".