You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>#### DotArray::get() can return a new instance of DotArray in case the accessed path is an array or it will return the raw data value or the default given value.
43
+
>##### REMEMBER: YOU NEED TO KNOW YOUR DATA
44
+
>##### DotArray::get() can return a new instance of DotArray in case the accessed path is an array or it will return the raw data value or the default given value
45
45
46
46
- **instantiation**:
47
-
- ```php
47
+
- ```php
48
48
new DotArray($array);
49
49
DotArray::create($array);
50
50
DotArray::createFromJson($jsonString);
51
-
```
51
+
```
52
52
53
53
- **get**:
54
-
- ```php
54
+
- ```php
55
55
// Because the key `sci-fi & fantasy` is array the returning value it will be a new instance of DotArray.
56
56
$dot('books.{sci-fi & fantasy}');
57
-
57
+
58
58
// Because the price is not an array, the result will be raw data, float in this case.
59
59
$dot('books.{sci-fi & fantasy}.0.price');
60
-
60
+
61
61
// Accessing the raw array.
62
62
$dot('books.{sci-fi &fantasy}')->toArray();
63
63
$dot->get('books.{sci-fi & fantasy}')->toArray();
64
-
64
+
65
65
// Accessing the last leaf and getting the raw data.
66
66
$dot('books.{sci-fi & fantasy}.0.name');
67
67
$dot->get('books.{sci-fi & fantasy}.0.name');
68
68
69
69
// Vanilla PHP.
70
70
$dot('books.{sci-fi & fantasy}.0.name');
71
71
$dot['books']['sci-fi & fantasy'][0]['name'];
72
-
```
72
+
```
73
73
74
74
- **get :: more-complex**:
75
-
- ```php
75
+
- ```php
76
76
// Using dotted key and accessing without getting confused.
77
77
// Allowed tokens for keeping the names with dot(.) togethers are: '', "", [], (), {}
0 commit comments