Advertisement
VitaliyKuznetsov

Untitled

Nov 15th, 2018
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. $marks = [];
  2. $types = [];
  3. foreach (BCatalogMark::model()->findAll() as $item) {
  4.     $marks[$item['id']] = [
  5.             'id' => $item['id'],
  6.             'alias' => $item['alias']
  7.     ];
  8. }
  9. foreach (BCatalogType::model()->findAll() as $item) {
  10.     $types[$item['id']] = [
  11.         'id' => $item['id'],
  12.         'alias' => $item['alias']
  13.     ];
  14. }
  15.  
  16. foreach ($data['type'] as $match) {
  17.     foreach ($types as $type) {
  18.         foreach ($marks as $mark){
  19.             if(
  20.                     in_array($mark['alias'], $alias) &&
  21.                     in_array($type['alias'], $alias) &&
  22.                     $type['id'] == $match['type'] &&
  23.                     in_array($mark['alias'], $match['marks'])    
  24.             ){
  25.                 //тут будет нужный тебе тип в $match, советую записывать их в массив и делать array_unique,
  26.                 // так как возможны повторы
  27.             }
  28.         }
  29.     }
  30.  
  31. //ПОМЕНЯЙ НА 6 строке на "array_push($alias, $item);"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement