定制 hugsbrugs/php-array 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hugsbrugs/php-array

Composer 安装命令:

composer require hugsbrugs/php-array

包简介

PHP Array Utilities

README 文档

README

This librairy provides utilities function to ease array manipulation

Build Status Coverage Status

Install

Install package with composer

composer require hugsbrugs/php-array

In your PHP code, load library

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\HArray\HArray as HArray;

Note: I couldn't use Array as namespace because it's a PHP reserved word so it's why namespace is HArray ...

Usage

Shuffle an array while preserving keys

HArray::shuffle_assoc(&$array);

Sort an array based on column filter and optional sort direction

HArray::array_sort_by_column(&$arr, $col, $dir = SORT_ASC);

Sort a 2 dimensional array based on 1 or more indexes.

$new_array = HArray::msort($array, $key, $sort_flags = SORT_REGULAR);

Recursively implodes an array with optional key inclusion

$string = HArray::recursive_implode($glue, array $array, $include_keys = false, $trim_all = true);

Transforms an object (and object of object) into an array

$new_array = HArray::object_to_array($obj);

Count in 2 dimensions arrays, number of rows in sub arrays

$count = HArray::sub_count($array);

Cuts a string into an array of strings depending of word count

$new_array = HArray::string_to_array($text, $word_count);

Inserts an element at a given position in an array

$array = ['pomme', 'poire', 'fraise', 'banane'];
$array = HArray::array_insert($array, 'kiwi', 2);
Array
(
    [0] => pomme
    [1] => poire
    [2] => kiwi
    [3] => fraise
    [4] => banane
)

$array = ['pomme', 'poire', 'fraise', 'banane'];
$array = HArray::array_insert($array, ['kiwi', 'mangue'], 2);
Array
(
    [0] => pomme
    [1] => poire
    [2] => kiwi
    [3] => mangue
    [4] => fraise
    [5] => banane
)

Unit Tests

composer exec phpunit

Author

Hugo Maugey visit my website ;)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固