All Projects → houdunwang → arr

houdunwang / arr

Licence: other
数组增强组件主要是对数组等数据进行处理,如无限级分类操作、商品规格的迪卡尔乘积运算等。

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to arr

Competitive Programming
Programming👨‍💻 Questions on BinarySearch💻, LeetCode💻, CodeChef💻, Codeforces💻,DSA 450
Stars: ✭ 188 (+203.23%)
Mutual labels:  array
PREBorderView
A very simple Objective-C UIView category for specifying single-sided borders.
Stars: ✭ 18 (-70.97%)
Mutual labels:  category
BitLens
🔎 Have your bits and eat them too! A C++17 bit lens container for vector types.
Stars: ✭ 20 (-67.74%)
Mutual labels:  array
java-notes
Complete Java Note for colleges in Nepal.
Stars: ✭ 30 (-51.61%)
Mutual labels:  array
Public-Method-CardGame-NiuNiu
纸牌游戏牛牛的最优算法及Method
Stars: ✭ 21 (-66.13%)
Mutual labels:  array
ZCategoryTool
ZCategoryTool
Stars: ✭ 37 (-40.32%)
Mutual labels:  category
pretty-d-array
Pretty printing multidimensional D arrays.
Stars: ✭ 16 (-74.19%)
Mutual labels:  array
HashMapC
A tiny library for using easily HashMap, arraylist in the C.
Stars: ✭ 21 (-66.13%)
Mutual labels:  array
FUPRAL
Fortran OO implementation of a generic container using an unlimited polymorphic class. Implementation of a resizable container array and a double linked list.
Stars: ✭ 18 (-70.97%)
Mutual labels:  array
CuVec
Unifying Python/C++/CUDA memory: Python buffered array ↔️ `std::vector` ↔️ CUDA managed memory
Stars: ✭ 73 (+17.74%)
Mutual labels:  array
php-collections
A collection library for php
Stars: ✭ 34 (-45.16%)
Mutual labels:  array
array-keyed-map
JS datastructure, like Map, but the keys are arrays
Stars: ✭ 29 (-53.23%)
Mutual labels:  array
linqjs
Perform queries on collections in the manner of C#s System.Linq in JavaScript
Stars: ✭ 14 (-77.42%)
Mutual labels:  array
Problem-Solving
contains all coding interview practice problems, data structures and algorithms implementations. 👨‍💻👨‍💻💥 🚩
Stars: ✭ 14 (-77.42%)
Mutual labels:  array
Data-Structures-Algorithms-Handbook
A series of important questions with solutions to crack the coding interview and ace it!
Stars: ✭ 30 (-51.61%)
Mutual labels:  array
my-swift-projects
An overview of my most relevant open-source projects on GitHub
Stars: ✭ 261 (+320.97%)
Mutual labels:  array
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (+104.84%)
Mutual labels:  array
arrayfire-haskell
Haskell bindings to ArrayFire
Stars: ✭ 52 (-16.13%)
Mutual labels:  array
longest
Get the length of the longest item in an array.
Stars: ✭ 31 (-50%)
Mutual labels:  array
pasvl
Array Validator (regular expressions for arrays, sort of)
Stars: ✭ 40 (-35.48%)
Mutual labels:  array

数组增强

数组增强组件主要是对数组等数据进行处理,如无限级分类操作、商品规格的迪卡尔乘积运算等。

安装组件

使用 composer 命令进行安装或下载源代码使用。

composer require houdunwang/arr

HDPHP 框架已经内置此组件,无需要安装

功能介绍

根据键名获取数据

如果键名不存在时返回默认值,支持键名的点语法

$d=['a'=>1,'b'=>2];
(new \houdunwang\arr\Arr())->get($d,'c','没有数据哟');

使用点语法查找:

$d = ['web' => [ 'id' => 1, 'url' => 'houdunwang.com' ]];
(new \houdunwang\arr\Arr())->get($d,'web.url');

排队字段获取数据

以下代码获取除 id、url以外的数据

$d = ['id' => 1,'url' => 'houdunwang.com','name'=>'后盾人'];
print_r((new \houdunwang\arr\Arr())->getExtName($d,['id','url']));

设置数组元素值支持点语法

$data = (new \houdunwang\arr\Arr())->set([],'a.b.c',99);

改变数组键名大小写

$data = array('name'=>'houdunwang',array('url'=>'hdphp.com'));
$data = (new \houdunwang\arr\Arr())->keyCase($data,1); 
第2个参数为类型: 1 大写  0 小写

不区分大小写检测键名是否存

(new \houdunwang\arr\Arr())->keyExists('Hd',['hd'=>'后盾网']);

数组值大小写转换

(new \houdunwang\arr\Arr())->valueCase(['name'=>'houdunwang'],1); 
第2个参数为类型: 1 大写  0 小写

数组进行整数映射转换

$data = ['status'=>1];
$d = (new \houdunwang\arr\Arr())->intToString($data,['status'=>[0=>'关闭',1=>'开启']]); 

数组中的字符串数字转为数值类型

$data = ['status'=>'1','click'=>'200'];
$d = (new \houdunwang\arr\Arr())->stringToInt($data); 

根据下标过滤数据元素

$d = [ 'id' => 1, 'url' => 'houdunwang.com','title'=>'后盾网' ];
print_r((new \houdunwang\arr\Arr())->filterKeys($d,['id','url']));
//过滤 下标为 id 的元素

当第三个参数为 0 时只保留指定的元素

$d = [ 'id' => 1, 'url' => 'houdunwang.com','title'=>'后盾网' ];
print_r((new \houdunwang\arr\Arr())->filterKeys($d,['id'],0));
//只显示id与title 的元素

获得树状结构

(new \houdunwang\arr\Arr())->tree($data, $title, $fieldPri = 'cid', $fieldPid = 'pid');
参数                   	说明
$data                 	数组
$title                	字段名称
$fieldPri             	主键 id
$fieldPid             	父 id

获得目录列表

(new \houdunwang\arr\Arr())->channelList($data, $pid = 0, $html = " ", $fieldPri = 'cid', $fieldPid = 'pid', $level = 1);
参数                      	说明 
data                 	操作的数组
pid                  	父级栏目的 id 值
html                	栏目名称前缀,用于在视图中显示层次感的栏目列表 
fieldPri              	唯一键名,如果是表则是表的主键
fieldPid              	父 ID 键名
level                 	等级(不需要传参数,系统运行时使用 ) 

获得多级目录列表(多维数组)

(new \houdunwang\arr\Arr())->channelLevel($data, $pid = 0, $html = " ", $fieldPri = 'cid', $fieldPid = 'pid') 
参数                          	说明
data                      	操作的数组
pid                      	父级栏目的 id 值
html                     	栏目名称前缀,用于在视图中显示层次感的栏目列表
fieldPri                 	唯一键名,如果是表则是表的主键
fieldPid                  	父 ID 键名

获得所有父级栏目

(new \houdunwang\arr\Arr())->parentChannel($data, $sid, $fieldPri = 'cid', $fieldPid = 'pid');
参数                          	说明
data                      	操作的数组
sid                      	子栏目
fieldPri                 	唯一键名,如果是表则是表的主键
fieldPid                  	父 ID 键名

是否为子栏目

(new \houdunwang\arr\Arr())->isChild($data, $sid, $pid, $fieldPri = 'cid', $fieldPid = 'pid')
参数                          	说明
data                      	操作的数组
sid                      	子栏目id
pid                      	父栏目id
fieldPri                 	唯一键名,如果是表则是表的主键
fieldPid                  	父 ID 键名

是否有子栏目

(new \houdunwang\arr\Arr())->hasChild($data, $cid, $fieldPid = 'pid')
参数                          	说明
data                      	操作的数组
cid                      	栏目cid
fieldPid                  	父 ID 键名

无限级栏目分类

(new \houdunwang\arr\Arr())->category($categories,$pid = 0,$title = 'title',$id = 'id',$parent_id = 'parent_id')
参数								说明
$categories						操作的数组
$pid								父级编号
$title                  		栏目字段
$id								主键名
$parent_id						父级字段名

迪卡尔乘积

(new \houdunwang\arr\Arr())->descarte($arr, $tmp = array())
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].