xakepehok / array-wildcard-explainer
List all array keys that match wildcard path
Installs: 942
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/xakepehok/array-wildcard-explainer
Requires
- php: >=7.4.0
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-09-24 12:50:30 UTC
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' * ] */