fix: 增加 array_column 兼容函数

This commit is contained in:
邹景立 2024-08-04 23:09:55 +08:00
parent 65c3dca0fd
commit 28de3a64cd
2 changed files with 27 additions and 0 deletions

25
helper.php Normal file
View 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;
}
}

View File

@ -14,6 +14,8 @@
// | github 代码仓库https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
include_once __DIR__ . '/helper.php';
spl_autoload_register(function ($classname) {
$pathname = __DIR__ . DIRECTORY_SEPARATOR;
$filename = str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';