Have you ever faced issue with your hosting server when you send html email with some email addresses in it? Replace your string with the following php regular expression.


//Html string you want to replace
$html_message=    “Its sample message with two email address in it. abc@gmail.com and xyz@yahoo.co.in”;

//Cleaned string
$cleaned_message = preg_replace(‘/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+)(\.)([A-Z]{2,4}\b)/i’, ‘$1.$3’, $html_message);

echo $cleaned_message;


Hide download link of a file

Posted: January 14, 2010 in php-mysql

This php script will hide the actual download path from visitors. You could allow download files like mysite.com/download.php?fileid=2 instead of mysite.com/photos/mypic.jpg.


Simply rewrite your search url to seo freindly.


Add the following code into your htaccess file

RewriteEngine on
RewriteRule ^search/(.*)$ search.php?keyword=$1

you can access the seach keyword in search.php page like this
$text_to_search = $_GET[‘keyword’];

Simple php script for sending email from localhost (or even in your server) using codeigniter’s email class with gmail username and password.  You can give your gmail credentials in the configuration area.


The following php code will help to rename a set of tables in a mysql database. You can add a prefix or suffix to all tables in a database. Also have an option to include or exclude some tables from the mass renaming.
Download source code from google code.