2016-04-14 4 views
0

мне нужно ориентироваться в этом массивеPHP поиск подмассив в массиве с конкретным ключом

Array 
(
    [0] => Array 
     (
      [isComplex] => 1 
      [condition] => and 
      [predicates] => Array 
       (
        [0] => Array 
         (
          [isComplex] => 1 
          [condition] => and 
          [predicates] => Array 
           (
            [0] => Array 
             (
              [isComplex] => 1 
              [condition] => and 
              [predicates] => Array 
               (
                [0] => Array 
                 (
                  [isComplex] => 
                  [field] => NAME 
                  [operator] => startswith 
                  [value] => as 
                  [ignoreCase] => 1 
                 ) 

                [1] => Array 
                 (
                  [isComplex] => 
                  [field] => MAIN_PHONE 
                  [operator] => startswith 
                  [value] => 06 
                  [ignoreCase] => 1 
                 ) 

               ) 

             ) 

            [1] => Array 
             (
              [isComplex] => 
              [field] => COD_FISC 
              [operator] => startswith 
              [value] => 98 
              [ignoreCase] => 1 
             ) 
//array multi 
           ) 

         ) 

        [1] => Array 
         (
          [isComplex] => 
          [field] => id 
          [operator] => startswith 
          [value] => 12 
          [ignoreCase] => 1 
         ) 

       ) 

     ) 


) 

результат, который я хочу получить испытывает только массивы с ключом Field

Es: результаты:

[0] => Array 
    (
    [isComplex] => 
    [field] => NAME 
    [operator] => startswith 
    [value] => as 
    [ignoreCase] => 1 
    ) 
[1] => Array 
(
    [isComplex] => 
    [field] => MAIN_PHONE 
    [operator] => startswith 
    [value] => 06 
    [ignoreCase] => 1 
) 
[2] => Array 
(
    [isComplex] => 
    [field] => COD_FISC 
    [operator] => startswith 
    [value] => 98 
    [ignoreCase] => 1 
) 
[3] => Array 
(
    [isComplex] => 
    [field] => id 
    [operator] => startswith 
    [value] => 12 
    [ignoreCase] => 1 
) 

Надеюсь, что этот код ясен. какие-либо предложения? Пробовал в нескольких модальностях, но до сих пор не нашел решения.

ответ

0

попробовать с помощью рекурсии:

$global_var; 

function recursive($node) 
{ 
    // grab informations into $global_var 
    if(has_no_subnodes) return; 
    else recursive($node->subField); 
} 
+0

Howto has_no_subnodes? –

+0

'if (! Isset (предикаты))'? –

+0

нет результатов ..... –