Convert plain text url’s to clickable links

Just copy this function and make your links clickable

function plain_url_to_link($string) {
    return preg_replace(
    '%(https?|ftp)://([-A-Z0-9./_*?&;=#]+)%i',
    '<a target="blank" rel="nofollow" href="$0" target="_blank">$0</a>', $string);
}
$str = "https://www.google.com is a search website, you can also visit yahoo.com and http://twitter.com";
echo plain_url_to_link($str);

Remove directory and all its content in PHP

To recursively delete all the contents in the directory and then the directory itself. This function checks for files and sub directories and delete them first before deleting the main folder.

$directory      = "uploads";
 
if(is_dir($directory)){
	recursiveRemoveDirectory($directory);
}
 
function recursiveRemoveDirectory($directory) {
    foreach(glob("{$directory}/*") as $file) {
        if(is_dir($file)) {
            recursiveRemoveDirectory($file);
        } else {
            unlink($file);
        }
    }
    rmdir($directory);
}

Remove index.php from URL in Codeigniter

Open applications/config/config.php and make the following changes :

Replace

$config['index_page'] = 'index.php';

With

$config['index_page'] = '';

And add the following code to a new file and save it as .htaccess inside the root folder :

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]