This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpautop($pee, $br = true) { | |
$pre_tags = array(); | |
if ( trim($pee) === '' ) | |
return ''; | |
$pee = $pee . "\n"; // just to make things a little easier, pad the end | |
if ( strpos($pee, '<pre') !== false ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//$timestamp = $row->date; // get your timestamp data from MySQL database's table field. | |
$timestamp = "2008-10-05 21:34:02"; | |
echo date("Y/n/d", strtotime( $timestamp )); | |
//other examples: | |
echo date("F j, Y g:i a", strtotime( $timestamp )); // October 5, 2008 9:34 pm | |
echo date("m.d.y", strtotime( $timestamp )); // 10.05.08 | |
echo date("j, n, Y", strtotime( $timestamp )); // 5, 10, 2008 | |
echo date("Ymd", strtotime( $timestamp )); // 20081005 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 身份證檢查函數 | |
function check_identity($id) { | |
$flag = false; | |
$id = strtoupper($id); | |
$d0 = strlen($id); | |
$qd = ""; | |
if ($d0 <= 0) {$qd=$qd."還沒填呢 !n";} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//讓Wordpress的中文圖片網址符合W3C檢驗的方法 | |
//讓get_the_post_thumbnail()符合W3C檢驗的方法 | |
//也就是說,讓中文的網址經過一層URL編碼 | |
$thumbnail_id = get_post_thumbnail_id($post->ID); | |
$src = wp_get_attachment_image_src( $thumbnail_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//----- 計算兩個日期之間的天數 -----// | |
$startTimeStamp = strtotime("2011/07/01"); | |
$endTimeStamp = strtotime("2011/07/17"); | |
$timeDiff = abs($endTimeStamp - $startTimeStamp); | |
$numberDays = $timeDiff/86400; // 86400 seconds in one day |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://maps.google.com/maps/geo?q=EC3M,+UK&output=csv&sensor=false'; | |
$data = @file_get_contents($url); | |
$result = explode(",", $data); | |
echo $result[0]; // status code | |
echo $result[1]; // accuracy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$stamp = strtotime("now"); | |
$orderid = $stamp - $_SERVER['REMOTE_ADDR']; | |
$orderid = str_replace(".", "", $orderid); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function aasort (&$array, $key) { | |
$sorter=array(); | |
$ret=array(); | |
reset($array); | |
foreach ($array as $ii => $va) { | |
$sorter[$ii]=$va[$key]; | |
} | |
asort($sorter); //由低至高排序 | |
//arsort($sorter); 由高至低排序 |