sunaoka/hash-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunaoka/hash-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sunaoka/hash-php

包简介

Merge one or more associative arrays recursively. This function does not append numeric indexes like array_merge_recursive() function.

README 文档

README

Latest License PHP Test codecov

Merge one or more associative arrays recursively

This function does not append numeric indexes like array_merge_recursive() function.

For example

array_merge_recursive()

$result = array_merge_recursive(['key' => 'old value'], ['key' => 'new value']);
print_r($result);
// => Array
// (
//     [key] => Array
//         (
//             [0] => old value
//             [1] => new value
//         )
//
// )

but, Hash::merge()

$result = Hash::merge(['key' => 'old value'], ['key' => 'new value']);
print_r($result);
// => Array
// (
//     [key] => new value
// )

Installation

composer require sunaoka/hash-php

Usage

use Sunaoka\Hash\Hash;

Hash::merge(['key' => 'old value'], ['key' => 'new value']);

// => Array
// (
//     [key] => new value
// )
use Sunaoka\Hash\Hash;

$array1 = ['a' => '1', 'b' => ['c' => '1', 'd' => '1', 'g' => ['h' => '1']]];
$array2 = ['a' => '2', 'b' => ['c' => '2', 'e' => '2', 'g' => ['h' => '2']]];
$array3 = ['a' => '3', 'b' => ['c' => '3', 'f' => '3', 'g' => ['h' => '3']]];

Hash::merge($array1, $array2, $array3);

// => Array
// (
//     [a] => 3
//     [b] => Array
//         (
//             [c] => 3
//             [d] => 1
//             [g] => Array
//                 (
//                     [h] => 3
//                 )
// 
//             [e] => 2
//             [f] => 3
//         )
// 
// )

统计信息

  • 总下载量: 352
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-24