一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

10個(gè)實(shí)用的PHP代碼片段

關(guān)鍵詞高亮
復(fù)制代碼 代碼如下:
function highlight($sString, $aWords) {
if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) {
return false;
}
$sWords = implode ('|', $aWords);
return preg_replace ('@/b('.$sWords.')/b@si', '<strong style="background-color:yellow">$1</strong>', $sString);
}

獲取你的Feedburner的用戶
復(fù)制代碼 代碼如下:
function get_average_readers($feed_id,$interval = 7){
$today = date('Y-m-d', strtotime("now"));
$ago = date('Y-m-d', strtotime("-".$interval." days"));
$feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed_url);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
$nb = 0;
foreach($xml->feed->children() as $circ){
$nb += $circ['circulation'];
}
return round($nb/$interval);
}

自動(dòng)生成密碼
復(fù)制代碼 代碼如下:
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength >= 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength >= 2) {
$vowels .= "AEUY";
}
if ($strength >= 4) {
$consonants .= '23456789';
}
if ($strength >= 8 ) {
$vowels .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}

壓縮多個(gè)CSS文件
復(fù)制代碼 代碼如下:
header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!//*[^*]*/*+([^/][^*]*/*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("/r/n", "/r", "/n", "/t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
/* your css files */
include('master.css');
include('typography.css');
include('grid.css');
include('print.css');
include('handheld.css');
ob_end_flush();

獲取短網(wǎng)址
復(fù)制代碼 代碼如下:
function getTinyUrl($url) {
return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}

根據(jù)生日計(jì)算年齡
復(fù)制代碼 代碼如下:
function age($date){
$year_diff = '';
$time = strtotime($date);
if(FALSE === $time){
return '';
}
$date = date('Y-m-d', $time);
list($year,$month,$day) = explode("-",$date);
$year_diff = date("Y") 主站蜘蛛池模板: 国产自产 | 亚洲精品在线不卡 | 综合色亚洲 | julia一区二区三区中文字幕 | 91在线欧美 | 久热中文字幕在线 | www.黑人| 在线观看视频网站www色 | 欧美在线观看视频 | 国产区精品福利在线观看精品 | 久久婷婷综合中文字幕 | 在线观看国产91 | 国产真实乱子伦精品视手机观看 | 成人免费网址在线 | 婷婷综合 在线 | 人禽伦交视频在线观看 | 成年女人男人免费视频播放 | 中国精品视频一区二区三区 | 色呦呦免费 | 国产福利2021最新在线观看 | 久久综合久久综合久久 | 国产成人午夜91精品麻豆剧场 | 97人人做人人添人人爱 | 黄色大片网站在线观看 | 五月天婷婷精品视频 | 激情区 | 四虎永久在线精品免费影视 | 国产精品第二页 | 天天天天天干 | 日本久久精品免视看国产成人 | 国产熟睡乱子伦视频观看软件 | 国产区精品福利在线观看精品 | 天天综合网天天综合色不卡 | 亚洲黄色美女视频 | 亚洲福利国产 | 一级做a爰片性色毛片黄书 一级做a爰片性色毛片男 | 91综合国产| 色综合久久中文 | 成人在线视频网址 | 婷婷激情四射网 | 国产成人精品免费视频大全五级 |