Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
5
Indexable
Never
$outputArray = [];

foreach ($listmodulall as $modul) {
  if ($modul->before_modul === 'mastermembercard') {
    $modul->anakan = [];
    foreach ($listmodulall as $childModul) {
      if ($childModul->before_modul === 'mastermembercard.indexidcash' || $childModul->before_modul === 'mastermembercard.indexchecksaldo') {
        $modul->anakan[] = $childModul;
      }
    }
    $outputArray[] = $modul;
  } elseif ($modul->before_modul === 'masterkompetitor') {
    $modul->anakan = [];
    foreach ($listmodulall as $childModul) {
      if ($childModul->before_modul === 'masterkompetitor.indexkompetitor') {
        $childModul->anakan = [];
        foreach ($listmodulall as $grandChildModul) {
          if ($grandChildModul->before_modul === 'masterkompetitor.indexkompetitor.indexsupermarket') {
            $childModul->anakan[] = $grandChildModul;
          }
        }
        $modul->anakan[] = $childModul;
      }
    }
    $outputArray[] = $modul;
  } elseif ($modul->before_modul === 'masterbuilding') {
    $modul->anakan = [];
    foreach ($listmodulall as $childModul) {
      if ($childModul->before_modul === 'masterbuilding.indexspacebuilding') {
        $modul->anakan[] = $childModul;
      }
    }
    $outputArray[] = $modul;
  } else {
    $outputArray[] = $modul;
  }
}