User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,391 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,896 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

PHP - How to Enable Hyperlinks ONLY in Posts

Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: PHP - How to Enable Hyperlinks ONLY in Posts

  #2  
Jun 15th, 2007
Hmmmm, well, using php, the first thing that comes up to my mind is to do something like this, however, it may turn out to be reaaallly slow with large posts. However, you can try it.

1. After submit, the content of the form gets exploded into an array.
2. Each value of this array is then checked for strings http://, or www., or @
3. If one of the following is found, you have to store the value again in the array with some extra data, which is - if it is an url, it should be something like <a href="value goes here">Value goes here</a>, or if it is an e-mail, it will be <a href="mailto:your value goes here">Your value here</a>.
4. Implode the array into a variable in the same order, in order to maintain text structure.
5. Write the post to a database, or do whatever you want with it.

Maybe the other guys here will figure out a smarter way, as it seems to me this is not the best solution.

Cheers.
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote  
All times are GMT -4. The time now is 1:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC