PHP code example of houdunwang / arr

1. Go to this page and download the library: Download houdunwang/arr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

houdunwang / arr example snippets


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

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

$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'=>'后盾网']);

$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 的元素

$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())->channelLevel($data, $pid = 0, $html = "&nbsp;", $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())->hasChild($data, $cid, $fieldPid = 'pid')
参数                          	说明
data                      	操作的数组
cid                      	栏目cid
fieldPid                  	父 ID 键名

(new \houdunwang\arr\Arr())->descarte($arr, $tmp = array())