Transfer the mass to function only if it exists



  • We need to compare a few masses to a match.

    $result = array_intersect($var_1,$var_2,$var_3,$var_4,$var_5,$var_6,$var_7);
    

    If there's a mass, we'll hand it over if we don't, we'll compare the rest for everyone. If not $var_2But there's the, uh, the others. $result = array_intersect($var_1,$var_3,$var_4,$var_5,$var_6,$var_7);if not $var_5,$var_6But there's the, uh, the others. $result = array_intersect($var_1,$var_2,$var_3,$var_4,$var_7); And so on.



    1. http://php.net/manual/ru/function.call-user-func-array.php - causes a function with a set of parameters.
    2. http://php.net/manual/ru/function.array-filter.php filtering the mass.

    The plan is that only the non-desert elements are left from the masses and are transmitted to them. array_intersect():

    $result = call_user_func_array(
        'array_intersect',
        array_filter(
            array( $var_1,$var_2,$var_3,$var_4,$var_5,$var_6,$var_7 ),
            function($a){ return isset($a)  &&  is_array($a)  &&  !!count($a);}
        )
    );
    

    http://ideone.com/hWmlwL




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2