定制 xakepehok/array-wildcard-explainer 二次开发

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

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

xakepehok/array-wildcard-explainer

最新稳定版本:0.1.2

Composer 安装命令:

composer require xakepehok/array-wildcard-explainer

包简介

List all array keys that match wildcard path

README 文档

README

This helper takes any complicated array and dot-styled wildcard path for passed array, and return new array with all keys, that match passed wildcard path. See examples below.

Installation:

composer require xakepehok/array-wildcard-explainer

Usage

<?php
use \XAKEPEHOK\ArrayWildcardExplainer\ArrayWildcardExplainer;

$array = [
    'direct' => 1,
    'nested' => [
        'value_1' => 11,
        'value_2' => 22,
        'value_3' => [
            ['value' => 111],
            ['value' => 222],
        ],
    ]
];

print_r(ArrayWildcardExplainer::explainOne($array, 'direct'))
/* will print
 *  [
 *    'direct'
 *  ]
 */
 

print_r(ArrayWildcardExplainer::explainOne($array, 'nested.*'))
/* will print
 *  [
 *    'nested.value_1',
 *    'nested.value_2',
 *    'nested.value_3',
 *  ]
 */
 

print_r(ArrayWildcardExplainer::explainOne($array, 'nested.value_3'))
/* will print
 *  [
 *    'nested.value_3'
 *  ]
 */
 

print_r(ArrayWildcardExplainer::explainOne($array, 'nested.*.*.value'))
/* will print
 *  [
 *    'nested.value_3.0.value',
 *    'nested.value_3.1.value'
 *  ]
 */

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2023-01-06