I’m getting this in my post,
[{"master":"80216","assign":["80491","80514","80575"]}]
Required Output
[{"master":"80216","assign":"80491"}] [{"master":"80216","assign":"80514"}] [{"master":"80216","assign":"80575"}]
Advertisement
Answer
This will do the trick. No explanation is needed. You can get it by going through the code.
$input = []; # your data array foreach ($input as $item) { $master = $item["master"]; foreach ($item["assign"] as $assign) { $output[] = [ "master" => $master, "assign" => $assign ]; } }