Page 1 of 1

php http:// dynamic text area ->/?

Posted: Sun Feb 22, 2004 2:32 pm
by timothye
hey ,
im using this code for a chat program (flash interface) can someone help with the httP;//,https://,and ftp . i would like to know how to make it so they dont have to type in the http:// it would just recognise it ..
sorry .i am just starting with php and dont really know much ,im a flash MX man !
thanks for the input
code i am using below works just fine .but i would like to accomplish what i adressed above
cheers


Code: Select all

$msg = eregi_replace( "(http|https|ftp)://([[]/\n+-=%&:_.~?]+[#[]+]*)","<b><a href="\\1://\\2" target="_blank">\\1://\\2</a></b><br>", $msg);

Posted: Sun Feb 22, 2004 5:42 pm
by timothye
bump ::

this would be greatly appreciated if someone has some input on this question !!?
cheers

Posted: Sun Feb 22, 2004 5:44 pm
by Illusionist

Code: Select all

$msg = eregi_replace( "((http|https|ftp)://)?([[]/\n+-=%&:_.~?]+[#[]+]*)","<b><a href="\\1://\\3" target="_blank">\\1://\\3</a></b><br>", $msg);
try that

Posted: Sun Feb 22, 2004 6:13 pm
by timothye
nope sorry m8 that didnt work .
what tat code did was bring up my url and display it before the typed url ..
so it was like this ->http://www,mysite.com://www.msn.com
and i dont know how to fix it ..i tried a few different things .but i dont know php as i said .so help again is much appreciated !:D:D::D

Posted: Sun Feb 22, 2004 6:27 pm
by Illusionist

Code: Select all

$msg = eregi_replace( "(http://|https://|ftp://)?([[]/\n+-=%&:_.~?]+[#[]+]*)","<b><a href="\\1\\3" target="_blank">\\1\\3</a></b><br>", $msg);
I'm fairly new to regular expressions myself... so! maybe that'll work!

Posted: Sun Feb 22, 2004 7:25 pm
by timothye
hey thanks again ,but that didnt work either ..that just posted this -> //:3 in the display window
i think i really need to read about this and how it all works.:D
but i thought maybe someone could help me to just complete this task ..
well tha :cry: nks anyway !
cheers m8

Posted: Sun Feb 22, 2004 7:28 pm
by Illusionist
change \\3 to \\2

Posted: Sun Feb 22, 2004 8:27 pm
by tsg
one more option:

Code: Select all

<?php
$msg = preg_replace ("/(ftp|http|https):\/\/([a-z0-9~#%@&:;=!',_crl\(\)\?\/\.\-\+\[\]\|\*\$\^\{\}]+)/i", "<a href="\\1://\\2" target="_blank">\\1://\\2</a>", $msg); 
?>