[Admin Edit: moved from viewtopic.php?t=78]
Can you use this same idea if you are pulling a url out of a database?? I want to see if the url starts with http:// and if it does show it as a link on the screen as it is. But if it doesn't add the http:// to it and then show it as a link on the screen. I have tried several different ways to pull this information from a $row["AgentHomePage"] but it seems to be skipping the else in my If statement. Any help would be greatly appreciated.
parsing URLs
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
This statement will check if your url starts with http:// and preappends it if needed
Code: Select all
<?php
$url = ( eregi("^http://", $row["AgentHomePage"]) ) ? $row["AgentHomePage"] : ("http://" . $row["AgentHomePage"]);
?>