3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array( "mac_address"=>"989096e255a1", "Username"=>"", "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"=>"", "morestuff" => array( "a" =>123, "b" =>"", "c" =>123, "d" =>123 ), ), ); $filtered = array_filter($arr, function($var) {return !empty($var);}); $filtered["attributes"] = array_filter($arr["attributes"], function($var) {return !empty($var);}); print_r($filtered);
Output for 5.6.30
Array ( [mac_address] => 989096e255a1 [status] => Known [attributes] => Array ( [Owner] => rogue@wpi.edu [IPAM-Hostname] => dresden.wpi.edu [IPAM-AdminState] => OK [IPAM-TimeStamp] => 2017-07-11 11:18:33 EDT [morestuff] => Array ( [a] => 123 [b] => [c] => 123 [d] => 123 ) ) )