3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array( "mac_address"=>"989096e255a1", "status" =>"Known", "attributes" => array( "Owner"=>"rogue@wpi.edu", "IPAM-Hostname"=>"dresden.wpi.edu", "IPAM-AdminState"=>"OK", "IPAM-NAS-IP-Address"=>"", "IPAM-NAS-Port-ID"=>"", "IPAM-RADIUS-VLAN"=>"", "IPAM-TimeStamp"=>"2017-07-11 11:18:33 EDT", "Guest Role ID"=>"", "MAC-Auth Expiry"=>"", "Username"=>"", ), "Username"=>"", ); $filtered = array_filter($arr, function($var) {if(is_array($var)){return array_map('array_filter', $var);}else{return !empty($var);}} ); print_r($filtered);
based on urX5R
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.2.6
Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be array, string given in /in/5r80U on line 22 Array ( [mac_address] => 989096e255a1 [status] => Known [attributes] => Array ( [Owner] => rogue@wpi.edu [IPAM-Hostname] => dresden.wpi.edu [IPAM-AdminState] => OK [IPAM-NAS-IP-Address] => [IPAM-NAS-Port-ID] => [IPAM-RADIUS-VLAN] => [IPAM-TimeStamp] => 2017-07-11 11:18:33 EDT [Guest Role ID] => [MAC-Auth Expiry] => [Username] => ) )
Output for hhvm-3.15.4
Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Warning: array_filter() expects parameter 1 to be an array or collection in /in/5r80U on line 22 Array ( [mac_address] => 989096e255a1 [status] => Known [attributes] => Array ( [Owner] => rogue@wpi.edu [IPAM-Hostname] => dresden.wpi.edu [IPAM-AdminState] => OK [IPAM-NAS-IP-Address] => [IPAM-NAS-Port-ID] => [IPAM-RADIUS-VLAN] => [IPAM-TimeStamp] => 2017-07-11 11:18:33 EDT [Guest Role ID] => [MAC-Auth Expiry] => [Username] => ) )