Newbie: test for string/ if-elseif
Posted: Fri May 27, 2005 12:46 pm
Hi all
I'm stumbling at the first hurdle here, wondering if anyone can give me a hint?
I'm trying to test for the presence of "http://" in a string then return one of two variables.
this always returns '$link2'. The problem is in the IF statement but I can't get my head around it.
Any help much appreciated
daveW
I'm stumbling at the first hurdle here, wondering if anyone can give me a hint?
I'm trying to test for the presence of "http://" in a string then return one of two variables.
Code: Select all
<?php
$url = "http://www.domain.co.uk";
$link1 = "<a href=\"";
$link2 = "<a href=\"http://";
if ( $url == "^(http://).*" )
{
$version = $link1;
}
elseif ( $url != "^(http://).*" )
{
$version = $link2;
}
echo $version,$url,"\">$url</a><br>";
?>Any help much appreciated
daveW