3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array("", " ", 0, false, array(), "45"); $r=0; foreach($a as $i => $s) if (trim($s) == "") $r.=$i; echo $r;
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.6
Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /in/4X3ct:4 Stack trace: #0 /in/4X3ct(4): trim(Array) #1 {main} thrown in /in/4X3ct on line 4
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 7.0.20, 7.1.5 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: trim() expects parameter 1 to be string, array given in /in/4X3ct on line 4 00134

preferences:
177.98 ms | 403 KiB | 220 Q