How can I build an array from string and values ?
For exemple :
string | value
|
objectId | 19
location.street | Rue des clochets
translations.fr.idTranslation | 4
And the result must be :
[
'objectId' => 19,
'location' => [
'street' => 'Rue des clochets'
],
'translations' => [
'fr' => [
idTranslation => 4
],
]
]
Obiviously, if the key already exists, it is complete, not duplicate.
Like : translation.fr.country | France
The array will become :
[
'object' => 19,
'location' => [
'street' => 'Rue des clochets'
],
'translations' => [
'fr' => [
'idTranslation' => 4,
'country' => 'France'
],
]
]
I think, using explode is the good way but I don't find the good syntax.
The head of my method is :
public function buildArray($key, $value) {
}
I call this method in a foreach.
And the array is a property.
Thank's for help.