@@ -102,6 +102,8 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
102
102
```
103
103
104
104
- **clear** *(empty array <=> [])*:
105
+ > Set the contents of a given key or keys to the given value (default is empty array).
106
+
105
107
- ```php
106
108
$dot->clear(' books.{sci-fi & fantasy}' );
107
109
$dot->clear(' books.{sci-fi & fantasy}' , null);
@@ -117,12 +119,21 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
117
119
$dot[' books.{sci-fi & fantasy}' ] = [];
118
120
```
119
121
122
+ - **delete** *(unset(...))*:
123
+ > Delete the given key or keys.
124
+
125
+ - ```php
126
+ $dot->delete(' books.{sci-fi & fantasy}' );
127
+ $dot->delete(' books.{sci-fi & fantasy}.0.name' );
128
+ $dot->delete([' books.{sci-fi & fantasy}.0' , ' books.{childre\' s books}.0' ]);
129
+ ```
130
+
120
131
- **merge**:
121
- > Merges one or more arrays into master recursively.
132
+ > Merges one or more arrays into master recursively.<br/>
122
133
If each array has an element with the same string key value, the latter
123
- will overwrite the former (different from array_merge_recursive).
134
+ will overwrite the former (different from array_merge_recursive).<br/>
124
135
Recursive merging will be conducted if both arrays have an element of array
125
- type and are having the same key.
136
+ type and are having the same key.<br/>
126
137
For integer-keyed elements, the elements from the latter array will
127
138
be appended to the former array.
128
139
@@ -144,30 +155,21 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
144
155
);
145
156
```
146
157
147
- - **delete** *(unset(...))*:
148
- - ```php
149
- $dot->delete(' books.{sci-fi & fantasy}' );
150
- $dot->delete(' books.{sci-fi & fantasy}.0.name' );
151
- $dot->delete([' books.{sci-fi & fantasy}.0' , ' books.{childre\' s books}.0' ]);
152
- ```
153
-
154
158
- **find**:
159
+ > Find the first item in an array that passes the truth test, otherwise return false.<br/>
160
+ The signature of the callable must be: `function ($value, $key)`.
161
+
155
162
- ```php
156
- /*
157
- Find the first item in an array that passes the truth test, otherwise return false
158
- The signature of the callable must be: `function ($value, $key)`.
159
- */
160
163
$book = $dot->get(' books.{childre\' s books}' )->find(function ($value, $key) {
161
164
return $value[' price' ] > 0;
162
165
});
163
166
```
164
167
165
168
- **filter**:
169
+ > Use a callable function to filter through items.<br/>
170
+ The signature of the callable must be: `function ($value, $key)`
171
+
166
172
- ```php
167
- /*
168
- Use a callable function to filter through items.
169
- The signature of the callable must be: `function ($value, $key)`
170
- */
171
173
$books = $dot->get(' books.{childre\' s books}' )->filter(function ($value, $key) {
172
174
return $value[' name' ] === ' Harry Potter and the Order of the Phoenix' ;
173
175
});
@@ -240,9 +242,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
240
242
```
241
243
242
244
- **toArray**:
243
- - ```php
244
- // Getting the internal raw array.
245
+ > Getting the internal raw array.
245
246
247
+ - ```php
246
248
// Example 1.
247
249
$dot->toArray();
248
250
@@ -251,9 +253,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
251
253
` ` `
252
254
253
255
- ** toJson** :
254
- - ` ` ` php
255
- // Getting the internal raw array as JSON.
256
+ > Getting the internal raw array as JSON.
256
257
258
+ - ` ` ` php
257
259
// Example 1.
258
260
$dot->toJson ();
259
261
@@ -262,6 +264,9 @@ DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{som
262
264
` ` `
263
265
264
266
- ** toFlat** :
267
+ > Flatten the internal array using the dot delimiter,
268
+ also the keys are wrapped inside {key} (1 x curly braces).
269
+
265
270
- ` ` ` php
266
271
$dot = DotArray::create(
267
272
[
0 commit comments