Edited by Hip Hop Artist, 03 September 2007 - 12:12 PM.
Changing To A Link (PHP)
Started by Hip Hop Artist, Sep 03 2007 12:12 PM
2 replies to this topic
#1
Posted 03 September 2007 - 12:12 PM
For my news section of my site I need a script that will take any urls that were typed into the body of text and turn them into links. Or that I can put a word right after the url and it will make whatever word i put into a link to the url i typed.
#2
Posted 03 September 2007 - 12:22 PM
What you want is something like a bbcode system, you can find some nice tutorials about exaclty this. Also check str_replace and preg_replace in php.net function list! Next thing would be regular expressions.
Edited by Balor, 03 September 2007 - 12:24 PM.
#3
Posted 03 September 2007 - 01:44 PM
A solution would be to search your text for 'http://' or even 'www' and to let php select the sentence until a space: ' ' is found. And put that in a <a> tag.
To search a text for words/characters, refer to:
http://be2.php.net/m...tion.strpos.php and http://be2.php.net/m...tion.strstr.php
To search a text for words/characters, refer to:
http://be2.php.net/m...tion.strpos.php and http://be2.php.net/m...tion.strstr.php
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
