PHP code example of xakepehok / array-wildcard-explainer

1. Go to this page and download the library: Download xakepehok/array-wildcard-explainer 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/ */

    

xakepehok / array-wildcard-explainer example snippets



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'
 *  ]
 */