File tree Expand file tree Collapse file tree 2 files changed +75
-1
lines changed Expand file tree Collapse file tree 2 files changed +75
-1
lines changed Original file line number Diff line number Diff line change
1
+ Recursive PHP ` array_keys() ` !
2
+ =============================
3
+
4
+ [ ![ Build Status] ( https://img.shields.io/travis/lucasantarella/php-array-keys-recursive/master.svg )] ( https://travis-ci.org/lucasantarella/php-array-keys-recursive )
5
+ ![ License] ( https://img.shields.io/github/license/lucasantarella/php-array-keys-recursive.svg )
6
+ ![ Issues] ( https://img.shields.io/bitbucket/issues/lucasantarella/php-array-keys-recursive.svg )
7
+
8
+ ## Description
9
+ A simple library for getting the ` array_keys() ` of a multidimensional array.
10
+
11
+ ## Installation
12
+ #### Composer
13
+ ``` bash
14
+ $ composer require lucasantarella/php-array-keys-recursive
15
+ ```
16
+
17
+ ## Usage
18
+ ``` php
19
+ <?php
20
+
21
+ require_once __DIR__ . '/vendor/autoload.php';
22
+
23
+ $input = [
24
+ 'person' => [
25
+ 'name' => [
26
+ 'first' => 'Luca',
27
+ 'middle' => 'Michele',
28
+ 'last' => 'Santarella'
29
+ ],
30
+ 'dob' => '11/11/1999',
31
+ 'knowledge' => [
32
+ 'programming' => [
33
+ 'languages' => [
34
+ 'PHP',
35
+ 'JS',
36
+ 'HTML',
37
+ 'SQL',
38
+ 'JAVA'
39
+ ]
40
+ ]
41
+ ]
42
+ ]
43
+ ];
44
+
45
+ $output = \LucaSantarella\ArrayKeysRecursive::getKeys($input);
46
+ ```
47
+ #### Result
48
+ ``` text
49
+ array (
50
+ 'person' =>
51
+ array (
52
+ 'name' =>
53
+ array (
54
+ 0 => 'first',
55
+ 1 => 'middle',
56
+ 2 => 'last',
57
+ ),
58
+ 0 => 'dob',
59
+ 'knowledge' =>
60
+ array (
61
+ 'programming' =>
62
+ array (
63
+ 'languages' =>
64
+ array (
65
+ 0 => 0,
66
+ 1 => 1,
67
+ 2 => 2,
68
+ 3 => 3,
69
+ 4 => 4,
70
+ ),
71
+ ),
72
+ ),
73
+ ),
74
+ )
75
+ ```
Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ public function testGetKeys()
82
82
public function testGetKeysWithDepth ()
83
83
{
84
84
$ output = ArrayKeysRecursive::getKeys (self ::$ testArray , 2 );
85
- var_export ($ output );
86
85
$ this ->assertEquals ([
87
86
'person ' => [
88
87
'name ' => [],
You can’t perform that action at this time.
0 commit comments