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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
timothye
Forum Newbie
Posts: 15
Joined: Sun Feb 01, 2004 2:36 pm
Location: Sweden/Sverige/USA

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

Post 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);
User avatar
timothye
Forum Newbie
Posts: 15
Joined: Sun Feb 01, 2004 2:36 pm
Location: Sweden/Sverige/USA

Post by timothye »

bump ::

this would be greatly appreciated if someone has some input on this question !!?
cheers
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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
User avatar
timothye
Forum Newbie
Posts: 15
Joined: Sun Feb 01, 2004 2:36 pm
Location: Sweden/Sverige/USA

Post 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
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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!
User avatar
timothye
Forum Newbie
Posts: 15
Joined: Sun Feb 01, 2004 2:36 pm
Location: Sweden/Sverige/USA

Post 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
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

change \\3 to \\2
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post 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); 
?>
Post Reply