php
get current time in UTC
Submitted by Rimu Atkinson on Wed, 06/07/2011 - 16:01
gmdate('Y-m-d H:i:s');
word trim
Submitted by Rimu Atkinson on Tue, 16/02/2010 - 21:18
Tagged:
function _super6_word_trim($string, $count, $ellipsis = FALSE){
$words = explode(' ', $string);
if (count($words) > $count){
array_splice($words, $count);
$string = implode(' ', $words);
if (is_string($ellipsis)){
$string .= $ellipsis;
}
elseif ($ellipsis){
$string .= '…';
}
}
return $string;
}convert smart quotes
Submitted by Rimu Atkinson on Tue, 16/02/2010 - 20:35
Tagged:
function convert_smart_quotes($string)
{
// First, replace UTF-8 characters.
$string= str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$string);
// Next, replace their Windows-1252 equivalents.
$string = str_replace(
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
array("'", "'", '"', '"', '-', '--', '...'),
$string);
return $string;
}