3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "1": "tag_es1;tag_es2;tag_es3", "2": "tag_en1;tag_en2;tag_en3" }, { "1": "tag_es1;tag_es2", "2": "tag_en1;tag_en2" } ]'; $arr = json_decode($json, true); foreach($arr as $key1 => $sub){ foreach($sub as $item){ $temp[] = explode(";", $item); } foreach($temp[0] as $key2 => $val){ $new[$key1][]= array_combine([1,2],array_column($temp, $key2)); } $temp =[]; } Var_dump($new);

preferences:
28.12 ms | 408 KiB | 5 Q