1. Month Display
/** month Displays
* @param int $m 1-12
* @param int $type 0:long 1:short (default 2:chinese
* @return String *
/function Format_month ($m, $type =0) {
$month = array (
Array (', ' January ', ' February ', ' March ', ' April ', ' may ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' D Ecember '), Array (', ' Feb ', ', ', ', ', ', ', ', ', ', ', ', ', ' Apr ', ' may
', ' June ', ' July ', ' Aug ', ' Sept ', ' Oct ', ' Nov ', ' Dec
Ay (', ' January ', ' February ', ' March ', ' April ', ' May ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December '))
;
return $month [$type] [$m];
}
2. Filter string, retain UTF8 alphanumeric Chinese and some symbols
/** filter string, preserving UTF8 alphanumeric characters in Chinese and partial symbols * @param string $OSTR * @return string/function Filter_utf8_char ($OSTR) {PR
Eg_match_all ('/[\x{ff00}-\x{ffef}|\x{0000}-\x{00ff}|\x{4e00}-\x{9fff}]+/u ', $ostr, $matches);
$str = Join (' ", $matches [0]);
if ($str = = ") {//contains special characters need to be handled $returnstr = ';
$i = 0;
$str _length = strlen ($OSTR);
while ($i <= $str _length) {$temp _str = substr ($ostr, $i, 1);
$ascnum = Ord ($temp _str);
if ($ascnum >=224) {$returnstr = $returnstr. substr ($ostr, $i, 3);
$i = $i + 3;
}elseif ($ascnum >=192) {$returnstr = $returnstr. substr ($ostr, $i, 2);
$i = $i + 2;
}elseif ($ascnum >=65 && $ascnum <=90) {$returnstr = $returnstr. substr ($ostr, $i, 1);
$i = $i + 1; }elseif ($ascnum >=128 && $ascnum <=191) {//special wordsCharacter $i = $i + 1;
}else{$returnstr = $returnstr. substr ($ostr, $i, 1);
$i = $i + 1;
}} $str = $returnstr;
Preg_match_all ('/[\x{ff00}-\x{ffef}|\x{0000}-\x{00ff}|\x{4e00}-\x{9fff}]+/u ', $str, $matches);
$str = Join (' ", $matches [0]);
return $str; }
3. Binary Stream Generation file
/** binary Stream Generation file
* $_post cannot interpret binary streams, requiring $GLOBALS [' http_raw_post_data '] or php://input
* $GLOBALS [' Http_ Raw_post_data '] and php://input are not available for Enctype=multipart/form-data
* @param String $file The file path to be generated
* @return boolean
/function Binary_to_file ($file) {
$content = $GLOBALS [' Http_raw _post_data ']; Requires php.ini to set
if (empty ($content)) {
$content = file_get_contents (' php://input '); Do not need php.ini settings, memory pressure small
}
$ret = File_put_contents ($file, $content, true);
return $ret;
}