mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-06 03:58:03 +08:00
fix: 增加 array_column 兼容函数
This commit is contained in:
parent
65c3dca0fd
commit
28de3a64cd
25
helper.php
Normal file
25
helper.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!function_exists('array_column')) {
|
||||||
|
/**
|
||||||
|
* PHP 版本兼容函数
|
||||||
|
* @param $input
|
||||||
|
* @param $columnKey
|
||||||
|
* @param $indexKey
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function array_column($input, $columnKey, $indexKey = null)
|
||||||
|
{
|
||||||
|
$result = array();
|
||||||
|
foreach ($input as $row) {
|
||||||
|
if (isset($row[$columnKey])) {
|
||||||
|
if ($indexKey !== null && isset($row[$indexKey])) {
|
||||||
|
$result[$row[$indexKey]] = $row[$columnKey];
|
||||||
|
} else {
|
||||||
|
$result[] = $row[$columnKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@
|
|||||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
include_once __DIR__ . '/helper.php';
|
||||||
|
|
||||||
spl_autoload_register(function ($classname) {
|
spl_autoload_register(function ($classname) {
|
||||||
$pathname = __DIR__ . DIRECTORY_SEPARATOR;
|
$pathname = __DIR__ . DIRECTORY_SEPARATOR;
|
||||||
$filename = str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';
|
$filename = str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user