From 8c48bc445c386581666672e5e7dc1b19f00cb80f Mon Sep 17 00:00:00 2001 From: devil_gong Date: Tue, 26 Feb 2019 15:46:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4each=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 31 ++++++++++++++++++++++++++++++- extend/base/Behavior.php | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/application/common.php b/application/common.php index 9250ff49d..be5a6fc3e 100755 --- a/application/common.php +++ b/application/common.php @@ -11,6 +11,35 @@ // 应用公共文件 +/** + * each函数 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-02-26 + * @desc description + * @param [array] &$data [输入参数] + */ +function FunEach(&$data) +{ + if(!is_array($data)) + { + return false; + } + + $res = []; + $key = key($data); + if($key !== null) + { + next($data); + $res[1] = $res['value'] = $data[$key]; + $res[0] = $res['key'] = $key; + } else { + $res = false; + } + return $res; +} + /** * 金额格式化 * @author Devil @@ -627,7 +656,7 @@ function Fsockopen_Post($url, $data = '') $port = isset($row['port']) ? $row['port'] : 80; $file = $row['path']; $post = ''; - while (list($k,$v) = each($data)) + while (list($k,$v) = FunEach($data)) { if(isset($k) && isset($v)) $post .= rawurlencode($k)."=".rawurlencode($v)."&"; //转URL标准码 } diff --git a/extend/base/Behavior.php b/extend/base/Behavior.php index 86f377f6a..a01b9beff 100755 --- a/extend/base/Behavior.php +++ b/extend/base/Behavior.php @@ -118,7 +118,7 @@ class Behavior $port = isset($row['port']) ? $row['port'] : 80; $file = $row['path']; $post = ''; - while (list($k,$v) = each($data)) + while (list($k,$v) = FunEach($data)) { if(isset($k) && isset($v)) $post .= rawurlencode($k)."=".rawurlencode($v)."&"; //转URL标准码 }