3v4l.org

run code in 300+ PHP versions simultaneously
<?php $biger_array = array( $a = array("DHL","ACS", "UPS"), $b = array("PayPal", "BrainTree", "UnionPay") ); $sizeof_biger_array = sizeof($biger_array); $array_with_size_of_smaller_arrays = array(); for ($x=0; $x<$sizeof_biger_array; $x++){ //$array_with_size_of_smaller_arrays[] =; $array_with_size_of_smaller_arrays[] = sizeof($biger_array[$x]); } function forLoopDynamic(array $array, array $number_of_vars_in_every_array) { //print 'Inside `aMemberFunc()`'; $sizeOfTheBigerArray = sizeof($array_with_size_of_smaller_arrays); for ($i=0; $i<$sizeOfTheBigerArray; $i++){ echo $number_of_vars_in_every_array[$i]; //for ($x=0; $x<($number_of_vars_in_every_array[$i]); $x++){ //echo $array[$x]; //} } } forLoopDynamic($a, $array_with_size_of_smaller_arrays); //echo $biger_array[0][0]; //echo $biger_array[1][0]; echo sizeof($array_with_size_of_smaller_arrays); //print_R($array_with_size_of_smaller_arrays);
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Undefined variable $array_with_size_of_smaller_arrays in /in/lQYCh on line 23 Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in /in/lQYCh:23 Stack trace: #0 /in/lQYCh(39): forLoopDynamic(Array, Array) #1 {main} thrown in /in/lQYCh on line 23
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 Warning: Undefined variable $array_with_size_of_smaller_arrays in /in/lQYCh on line 23 Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in /in/lQYCh:23 Stack trace: #0 /in/lQYCh(39): forLoopDynamic(Array, Array) #1 {main} thrown in /in/lQYCh on line 23
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Warning: Undefined variable $array_with_size_of_smaller_arrays in /in/lQYCh on line 23 Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in /in/lQYCh:23 Stack trace: #0 /in/lQYCh(39): forLoopDynamic(Array, Array) #1 {main} thrown in /in/lQYCh on line 23
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: array_with_size_of_smaller_arrays in /in/lQYCh on line 23 Warning: sizeof(): Parameter must be an array or an object that implements Countable in /in/lQYCh on line 23 2
Output for 7.3.32 - 7.3.33
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /in/lQYCh on line 23 2
Output for 7.0.0 - 7.0.24, 7.1.0 - 7.1.33
Notice: Undefined variable: array_with_size_of_smaller_arrays in /in/lQYCh on line 23 2

preferences:
216.93 ms | 402 KiB | 224 Q