FREE PHP Scripts and Snippets

Ready to use Free PHP scripts and snippets to use in your projects.
All Free Scripts & Snippets Complete PHP Scripts

Make URLs in plain text clickable [PHP]

>> Share on Facebook & Impress your friends <<

This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.

<?php

/*

This fuction expects plain text with some urls to be passed to it.

It will find those URLs and make them Clickable Hyper links.
*/


function makeLinksClickable ($plaintext) 
{  

 $plaintext = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',  
 '<a href="\1">\1</a>', $plaintext);  
 $plaintext = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',  
 '\1<a href="http://\2">\2</a>', $plaintext);  
 $plaintext = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',  
 '<a href="mailto:\1">\1</a>', $plaintext);  
  
return $plaintext;
  
}


?>


Request Custom Snippet

Just $5 Onwards

 

Previously Ordered Snippets

I want php function to replace all links from a text and replace it will say ***Login to View***
Price $5 Order Now

I want to replace all links in a text with hyper links but all links should open in new window.
Price $5 Order Now

Random PHP Scripts and Snippets

Detect Valid Email address with PHP

A very simple php snippet to check if an email id is valid or not. If the email address is...

[PHP] generate keywords from text function

This is a simple function written in PHP to generate keywords from any text. Just pass any free text to...

[PHP] Time ago calculation function

It is a very nice PHP time ago function. You gave pass any date to it and it will tell...

Make URLs in plain text clickable [PHP]

This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.

PHP extract multiple emails from text

PHP Script to scan a text and extract all email ids contained in the text. It outputs email addresses as...

Extracting all numbers from a String [PHP]

This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...

PHP Code to list all files in a folder

This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....

PHP - Extract all links from a web page

PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...