Skip to content

Commit 8b0cd1a

Browse files
Added readme
1 parent 0406445 commit 8b0cd1a

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
```

tests/ArrayKeysRecursiveTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public function testGetKeys()
8282
public function testGetKeysWithDepth()
8383
{
8484
$output = ArrayKeysRecursive::getKeys(self::$testArray, 2);
85-
var_export($output);
8685
$this->assertEquals([
8786
'person' => [
8887
'name' => [],

0 commit comments

Comments
 (0)