|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Executing if and else at time
Hello:
I have a var called $Enlace that contains a string with one or more URL. In my case contains 2 URL in the same string separated by this ";" Here is the code: <?php while ($row = mysql_fetch_array($result)){ $Enlace=$row['Enlace']; if (ereg(";", $Enlace)) { foreach (split(";", $Enlace) as $url) { if (ereg("@", $url)) { $href.="<a href="mailto:$url" class="arialRosaOscuro11Link" target="blank">$Enlace</a>"; $href.="<br>"; } elseif (ereg("http://",substr($url,0,7)) || ereg("https://",substr($url,0,8))) { $href.="<a href='$url' class='arialRosaOscuro11Link' target='blank'>$Enlace</a>"; $href.="<br>"; } else { $href.="<a href='http://".$url."' class='arialRosaOscuro11Link' target='blank'>$Enlace</a>"; $href.="<br>"; } } }else{ if (ereg("@", $Enlace)) $href="<a href="mailto:$Enlace" class="arialRosaOscuro11Link" target="blank">$Enlace</a>"; elseif (!ereg("http://",(substr($url,0,7))) || !ereg("https://",(substr($url,0,8)))) $href="<a href='http://".$Enlace."' class='arialRosaOscuro11Link' target='blank'>$Enlace</a>"; else $href="<a href='$Enlace' class='arialRosaOscuro11Link' target='blank'>$Enlace</a>"; } ?> The problem is that everything works fine but when I have per example this: "http://www.escardio.org/congresses/World_Congress_Cardiology_2006/;webmaster@escardio.org" my code reads separated both url's but writes the next: http://www.escardio.org/congresses/World_Congress_Cardiology_2006/;webmaster@escardio.org http://www.escardio.org/congresses/World_Congress_Cardiology_2006/;webmaster@escardio.org which one with one link, one mailto and one www Which could be the problem? Thanks in advance |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Executing if and else at time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|