原创 tp5 分頁查詢同時循環操作數據

Db::name('orders') ->where($map) ->order('create_time desc') ->paginate(50) ->each(function($item, $ke

原创 PHP 取中文字之間的數字 (滿4元減1元)

主要是判斷淘寶的滿減 $str = "滿4元減1元"; $po1= (strpos($str,"滿")); $po2= (strpos($str,"元減")); echo '取值:'.substr($str,$po1+3,$po2-3);

原创 中文年月日 日期轉成時間戳

$time = '2020年01月01日 00:00:00'; public function dateToTime($format='Y年m月d日 H:i:s', $time) { $dt = date_create_from

原创 Tp5 調用阿里雲OSSsdk

<?php //阿里雲oss存儲 namespace app\common\controller; vendor('aliyun-oss.autoload'); use OSS\OssClient; use OSS\Core\OssE

原创 蘇寧佣金鏈接獲取商品ID

$str = 'https://sugs.suning.com/C6cTlAxy'; $content = file_get_contents($str); preg_match('/id="ga_itemDataBean_itemID

原创 淘寶客商品 獲取詳情圖片(接口已掛)

https://open.21ds.cn/index/index/openapi/id/73.shtml?ptype=1  我現在用的是他家的接口   下面的接口不能用了 $.ajax({       url: "https://hw

原创 支付寶 APP支付

 創建充值: public function createRechargeOrder() { $mobile = $this->request->post('mobile')?$this->request->post('

原创 php 生成6位隨機字符串

/** * 生成隨機字母加數字 字符串 * @param int $len 要生成字符串長度 * @param null $chars 要生成字符串包含的字符 * @return strin

原创 openssl_public_encrypt(): key parameter is not a valid public key

public key 不管一行還是 64個字符分行都會報這個錯誤。 找了一下用這種方法成功了 $public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ..."; $public_key = "

原创 JSON 字符串和對象對比

$str = '{"extraMap":"{\"app\":\"activitylist.html\"}"}'; var_dump(json_decode($str)); $str1 = '{"extraMap":{"app":"ac

原创 php下載功能

<?php $file_name = "57c79b825dbd8.jpg"; $file_dir = "/Upload/download/"; if (!file_exists($file_dir . $file_name))

原创 php原生 出現要輸出兩條數據的情況的解決辦法

<li> <div class="pbox"> <a class='ajax' href="products/pro1.html" title="2016秋季九款英倫風男童格子襯衫 特價品牌童裝"> <div class="p

原创 PHP 含祕鑰的可逆加密解密算法

原文鏈接:http://www.mafutian.net/292.html // 加密算法 function encrypt($data, $key) { $key = md5($k

原创 tp5 讀數據庫的時候把時間戳格式字段改爲日期格式

$result = Db::name("articles") ->alias('A') ->join('article_cate B', 'A.cate = B.id')

原创 PHP獲取文件夾下的所有.png後綴的圖片

$img_list = glob("./../public/img/haibao/*.png");