DotNotationParser is a simple parser that will parse foo.bar.baz
into [ 'foo', 'bar', 'baz' ]
and foo."bar.baz"
into [ 'foo', 'bar.baz' ]
.
- php: >=7.1
Install the latest version with:
composer require 'quorum/dot-notation'
Class DotPathParser
Parse strings like foo."bar.baz".quux into [ 'foo', 'bar.baz', 'quux' ]
function parse(string $path) : array
Parse a given dot notation path into it's parts
The path is expected to be a string of dot separated keys, where keys can be
quoted with double quotes. Backslashes are used to escape double quotes inside
quoted keys.
'foo.bar.baz'
=>[ 'foo', 'bar', 'baz' ]
'foo."bar.baz"'
=>[ 'foo', 'bar.baz' ]
'foo."bar.baz".quux'
=>[ 'foo', 'bar.baz', 'quux' ]
'foo."bar\"baz".quux'
=>[ 'foo', 'bar"baz', 'quux' ]
Throws: \Quorum\DotNotation\Exceptions\ParseException
- string[]