Hello. I allow members to post statuses on my website and i want to check links. And if that text includes "www" i want to make that a link. How would i check this everytime i pull the status from the database to show it on the page

Recommended Answers

All 2 Replies

Here is a page with similar code http://css-tricks.com/snippets/php/find-urls-in-text-make-links/. As stated in the page all links must start with "http://", "https://" or the like for the regular expression to match it.

Sanitize the data before saving the status to the database but do not transform the text URLs into links until your script pulls the status from the database and run this function when printing out the status text to the browser.

Alls you should have to do is change the $text variable to whatever variable you declare for the status text.

If this seems to solve your problem then feel free to close the thread so others know that it is solved. If you have any other questions keep it open until you are satisfied.

Thank you this worked great! :)

Here is a page with similar code http://css-tricks.com/snippets/php/find-urls-in-text-make-links/. As stated in the page all links must start with "http://", "https://" or the like for the regular expression to match it.

Sanitize the data before saving the status to the database but do not transform the text URLs into links until your script pulls the status from the database and run this function when printing out the status text to the browser.

Alls you should have to do is change the $text variable to whatever variable you declare for the status text.

If this seems to solve your problem then feel free to close the thread so others know that it is solved. If you have any other questions keep it open until you are satisfied.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.