承接 cygnite/array-manipulator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cygnite/array-manipulator

最新稳定版本:v1.3

Composer 安装命令:

composer require cygnite/array-manipulator

包简介

Array Element Reader As String Path

README 文档

README

Cygnite Array Manipulator component used for simple array manipulation and reading array value using simple string path.

#Installation

Array Manipulator uses Composer for installation. For installing composer documentation, please refer to getcomposer.org. Add following into your composer.json.

"cygnite/array-manipulator" : "1.*"

#Usage

Cygnite array accessor used to read values from multi multidimensional array. It helps when you want to beautify your syntax and easy to access values. You can read values as below.

#Example

$array = [
         'profile' => [
             "experience"  => [
                 "field" => "Web Development",
                 "technology"    => "PHP"
             ]
         ]
     ];
$arrayAccessor = (new ArrayAccessor())->set($array);
echo $arrayAccessor->toString('profile.experience.field'); // output: Web Development

In some cases your array key may contains dot(.) which will make system confused whether it should look for next key or same. In such cases while getting value you need to provide key as underscore or dash prefix as below.

$array2 = [
         'profile' => [
             "experience"  => [
                 "technology.version"  => "Welcome to PHP v5.4"
             ]
         ]
     ];
$arrayAccessor = (new ArrayAccessor())->set($array1);
echo $arrayAccessor->toString('profile.experience.technology_version'); // output: Welcome to PHP v5.4

#Getting default value if array element not exists

$array3 = [
         'profile' => [
             "experience"  => '4 Years'
         ]
     ];
$arrayAccessor = (new ArrayAccessor())->set($array3);
echo $arrayAccessor->toString('profile.experience.area', 'Application Development'); // output 5 years

Using Closure Syntax

$array4 = [
         'profile' => [
             "author"  => 'Sanjoy Dey'
         ]
     ];
$arrayAccessor = ArrayAccessor::make(function($a) use ($array4)
{
    return $a->set($array4);
});
echo $arrayAccessor->toString('profile.author');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固