Category: Linux


How to remove \n from a string in PHP

// Variable decleared
$foo =

this
is
a
block

“;
function nl2br_limit($string, $num){

$dirty = preg_replace(‘/\r/’, ”, $string);
$clean = preg_replace(‘/\n{4,}/’, str_repeat(“”, $num), preg_replace(‘/\n/’, ‘ ‘, $dirty));

return nl2br($clean);
}

echo nl2br_limit($foo,’4′);

Remove (4) if u want for all. enjoy :)

Cron Job setting for Linux

*                 *                   *                 *                   *                                 /usr/local/bin/php /home/domainname/public_html/filename

min          hour            Day    of    month         Day of Week

Powered by WordPress. Theme: Motion by 85ideas.