The key holds null, and get() gives the default for null values as well as for missing paths. Use has() to check whether the key exists:
$dot = dot(['a' => null]);
$dot->get('a', 'x'); // "x"
$dot->has('a'); // trueThe key exists with that value. Only missing paths and null values give the default. Use ?: for a fallback on any empty value:
dot(['a' => []])->get('a') ?: 'x'; // "x"config.app.name looks for ["config"]["app"]["name"]. Escape the dot: config.app\.name. In a double-quoted PHP string, write "config.app\\.name".
Nothing matched: the array before the * is missing, empty, or not an array, or no element reached the last *. Pass [] as the default when you want an empty list:
dot(['users' => []])->get('users.*.name', []); // []When keys follow the last *, elements that aren't arrays are skipped. Branches that miss a key before the last * are skipped too. Elements that are arrays but miss the rest of the path are kept, with the default as their value (the same as a null value).
Wildcards only update existing elements; they never create them. Write to an index instead: set('users.0.active', true).
With a *, has() is true only when every matched element has the path. Check the values instead when one is enough:
$emails = dot($data)->get('users.*.email', []);
$anyEmail = array_filter($emails, fn ($email) => $email !== null) !== [];A trailing * means the elements, so users becomes []. Use delete('users') to remove the key.
A DotArray works on its own copy. Use Reference Mode to write to your array.
Encoding failed, usually because of invalid UTF-8. Pass JSON_THROW_ON_ERROR to see why:
$dot->toJson(null, JSON_THROW_ON_ERROR); // throws JsonException with the reason