I'm getting an array from $json_a = json_decode($filecontent, true):
Array (
[meta_titles] => Array (
[0] => Just another site
[1] => Test test
[2] => This is a test
)
[tag_titles] => Array (
[0] => Test 1
[1] => Value 2
[2] => String 3
)
)
I would like to modify the array as following:
Array (
[meta_titles] => Array (
Just another site => Just another site
Test test => Test test
This is a test => This is a test
)
[tag_titles] => Array (
Test 1 => Test 1
Value 2 => Value 2
String 3 => String 3
)
)
So values become the keys. Would somebody have an idea?
EDIT: My code so far:
$json_a = json_decode($filecontent, true);
$newjson = array();
foreach($json_a as $category) {
$newjson[$category] = array_combine(array_values($category), $category);
}
$json = json_encode($newjson, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
Thanks a lot