I have specific string to parse, and create php array key value pair out of it. Was not clever about this, cannot find suitable solution at this point. The string looks like this:
{xxx} some text 1{*|, some text 2 {xxx}}{*|, some text 3 {xxx}}{*|, 1 {xxx} some text 4}{*|, 1 {xxx} some text 5}
And I need to create php array like this:
[
'{xxx} some text 1' => 'some text 2 {xxx}'
'{xxx} some text 1' => 'some text 3 {xxx}'
'{xxx} some text 1' => '1 {xxx} some text 4'
'{xxx} some text 1' => '1 {xxx} some text 5'
]
What have I tried:
First replace {xxx} this curly braces with something else, so I am left with less of them
$value = str_replace('@#', '{', $value); $value = str_replace('#@', '}', $value);Now I tried somehow to explode based on }{ rule, but somehow I it did not work for me.
I tried a bunch of stuff, but code is messy to paste it here, but if someone experienced can point me to the right path I would be very grateful. Maybe there is better approach for this issue which I cannot see with the lack of experience.
{*|,? Also, I think your example is wrong-- you repeatsome text 1in your "output" array.