Display the drop-down list

Test of filter_var_array()

Example #1 : test success
Example #2 : test failed
Example #1
$input = [
  
=> [
    
'product_id' => 'libgd<script>',
    
'component' => '10',
    
'versions' => '2.0.33',
    
'testscalar' => [
      
=> '2',
      
=> '23',
      
=> '10',
      
=> '12',
    ],
    
'testarray' => '2',
  ],
  
=> [
    
'product_id' => 'FILTER_SANITIZE_ENCODED',
    
'component' => [
      
'filter' => 'FILTER_VALIDATE_INT',
      
'flags' => 'FILTER_FORCE_ARRAY',
      
'options' => [
        
'min_range' => 1,
        
'max_range' => 10,
      ],
    ],
    
'versions' => 'FILTER_SANITIZE_ENCODED',
    
'doesnotexist' => 'FILTER_VALIDATE_INT',
    
'testscalar' => [
      
'filter' => 'FILTER_VALIDATE_INT',
      
'flags' => 'FILTER_REQUIRE_SCALAR',
    ],
    
'testarray' => [
      
'filter' => 'FILTER_VALIDATE_INT',
      
'flags' => 'FILTER_FORCE_ARRAY',
    ],
  ],
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'mixed' => [
      
'product_id' => 'libgd%3Cscript%3E',
      
'component' => [
        
=> 10,
      ],
      
'versions' => '2.0.33',
      
'doesnotexist' => NULL,
      
'testscalar' => false,
      
'testarray' => [
        
=> 2,
      ],
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #2
$input = [
  
=> [
    
'width' => 2,
    
'length' => 3,
    
'height' => 4,
    
'weight' => 5,
  ],
  
=> [
    
'width' => [
      
'filter' => 'FILTER_CALLBACK',
      
'options' => 'double',
    ],
    
'length' => [
      
'filter' => 'FILTER_CALLBACK',
      
'options' => '$cube',
    ],
    
'height' => [
      
'filter' => 'FILTER_CALLBACK',
      
'options' => 'pbx_callbacks::double',
    ],
    
'weight' => [
      
'filter' => 'FILTER_CALLBACK',
      
'options' => [
        
=> '$object',
        
=> 'cube',
      ],
    ],
  ],
]
$expected_output = [
  
'result' => [
    
'mixed' => [
      
'width' => 4,
      
'length' => 27,
      
'height' => 8,
      
'weight' => 125,
    ],
  ],
  
'php_version' => '5.6.8 WINNT i586',
]
$test_output = [
  
'result' => [
    
'mixed' => [
      
'width' => '2',
      
'length' => '3',
      
'height' => '4',
      
'weight' => '5',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]