Display the drop-down list

Test of compact()

Example #1 : test failed
Example #2 : test success
Example #1
$input = [
  
'var1' => '$city',
  
'data1' => 'San Francisco',
  
'var2' => '$state',
  
'data2' => 'CA',
  
'var3' => '$event',
  
'data3' => 'SIGGRAPH',
  
'var4' => '$location_vars',
  
'data4' => [
    
=> 'city',
    
=> 'state',
  ],
  
=> 'event',
  
=> 'nothing_here',
  
=> '$location_vars',
]
$expected_output = [
  
'result' => [
    
'array' => [
      
'event' => 'SIGGRAPH',
      
'city' => 'San Francisco',
      
'state' => 'CA',
    ],
  ],
  
'php_version' => '5.6.8 WINNT i586',
]
$test_output = [
  
'result' => [
    
'array' => [
      
'event' => 'SIGGRAPH',
      
'city' => 'San Francisco',
      
'state' => 'CA',
    ],
  ],
  
'errors' => [
    
=> [
      
'code' => 2,
      
'message' => 'Cannot call compact() dynamically',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #2
$input = [
  
'var1' => '$city',
  
'data1' => 'San Francisco',
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'array' => NULL,
  ],
  
'errors' => [
    
=> [
      
'code' => 2,
      
'message' => 'compact() expects at least 1 parameter, 0 given',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]