$config = Config::getConfig('common');
$contract_carriers = $config[$market . "_" . $clearing . '_contract_carriers']; // f**ing php array
$interline_carriers = $config[$market . "_" . $clearing . '_interline_carriers']; // another f**ing array
// $marketing_carriers - is also array

$sets = [];
foreach ($marketing_carriers as $mc) {
  $sets[] = array_unique(array_intersect(
    array_merge(
      [$mc],
      array_intersect(
        isset(self::$interlines[$mc]) ? self::$interlines[$mc] : [],
        array_merge(
          $marketing_carriers,
          $interline_carriers
        )
      )
    ),
    $contract_carriers
  ));
}
By Anonymous, 2018-01-16 10:56:13