PhpAssocMap v1.0.0 PhpAssocMap View Source
Link to this section Summary
Functions
Gets the document AST from leex and yecc parser. The ast is automatically obtain from to_tuple/1 and to_map/1
Converts a map structure to an associative array string. The string key and value are single quoted
Converts a keyword list structure to an associative array string. The string key and value are single quoted
Parses an associative array string (or charlist) to a key-valued map. Both single and double quotes are supported
Parses an associative array string (or charlist) to a key-valued keyword list. Both single and double quotes are supported
Link to this section Functions
ast(chars) View Source
Gets the document AST from leex and yecc parser. The ast is automatically obtain from to_tuple/1 and to_map/1
## Exmples
iex> PhpAssocMap.ast("['key'=>['another_key'=>'value']]")
[{{:string, 1, "key"}, [{{:string, 1, "another_key"}, {:string, 1, "value"}}]}]
from_map(map) View Source
Converts a map structure to an associative array string. The string key and value are single quoted
The returned document will not be formatted yet. Use PhpAssocMap.Exploder.explode/1 or PhpAssocMap.Exploder.explode/2 to have it formatted.
## Exmples
iex> PhpAssocMap.from_map(%{"key" => %{"another_key" => "value"}})
"['key'=>['another_key'=>'value']]"
from_tuple(tuple) View Source
Converts a keyword list structure to an associative array string. The string key and value are single quoted
The returned document will not be formatted yet. Use PhpAssocMap.Exploder.explode/1 or PhpAssocMap.Exploder.explode/2 to have it formatted.
## Exmples
iex> PhpAssocMap.from_tuple([{"key", [{"another_key", "value"}]}])
"['key'=>['another_key'=>'value']]"
to_map(string) View Source
Parses an associative array string (or charlist) to a key-valued map. Both single and double quotes are supported.
Note: If the string starts with <?php return
, it'll be ignored
## Exemples
iex> PhpAssocMap.to_map("['key' => ['another_key' => 'value']]")
%{"key" => %{"another_key" => "value"}}
iex> PhpAssocMap.to_map("<?php return ['key' => ['another_key' => 'value']];")
%{"key" => %{"another_key" => "value"}}
to_tuple(string) View Source
Parses an associative array string (or charlist) to a key-valued keyword list. Both single and double quotes are supported.
Note: If the string starts with <?php return
, it'll be ignored
## Exemples
iex> PhpAssocMap.to_tuple("['key' => ['another_key' => 'value']]")
[{"key", [{"another_key", "value"}]}]
iex> PhpAssocMap.to_tuple("<?php return ['key' => ['another_key' => 'value']];")
[{"key", [{"another_key", "value"}]}]