3v4l.org

run code in 300+ PHP versions simultaneously
<?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"=>"" ); $trimmedArray = array_map('trim', $arr); $filtered = array_filter($trimmedArray, function($var){return !empty($var);} ); print_r($trimmedArray); print_r($filtered);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /in/MHHX9:21 Stack trace: #0 [internal function]: trim(Array) #1 /in/MHHX9(21): array_map('trim', Array) #2 {main} thrown in /in/MHHX9 on line 21
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /in/MHHX9:21 Stack trace: #0 [internal function]: trim(Array) #1 /in/MHHX9(21): array_map('trim', Array) #2 {main} thrown in /in/MHHX9 on line 21
Process exited with code 255.
Output for 7.3.24 - 7.3.33, 7.4.12 - 7.4.33
Warning: trim() expects parameter 1 to be string, array given in /in/MHHX9 on line 21 Array ( [mac_address] => 989096e255a1 [status] => Known [attributes] => [Username] => ) Array ( [mac_address] => 989096e255a1 [status] => Known )

preferences:
119.06 ms | 402 KiB | 118 Q