3v4l.org

run code in 300+ PHP versions simultaneously
<?php $relationships=array( array(70), array(70, 71), array(70, 71, 72), array(70, 71, 72), array(70, 71), array(80), array(70, 71), array(70, 71, 72), array(70, 71, 72), array(70, 71, 72), array(70, 71), array(70, 71, 72), array(70, 71, 72, 68) ); $old_count = 0; $index = 0; foreach($relationships as $val){ $tmp = array(); $value = array(); $count = count($val); if($count == 1){ $old_count = 0; $level = array(); $index++; $level[] = $index; } if($old_count == $count) $level[($count-1)] = ($level[($count-1)] == "" || $level[($count-1)] == null) ? 1 : ++$level[($count-1)]; else if($old_count > $count){ $level[($count-1)] = ($level[($count-1)] == "" || $level[($count-1)] == null) ? 1 : ++$level[($count-1)]; for($j = $count; $j <= $old_count; $j++) $level[$j] = 1; }else $level[$count] = 1; for($i = 0; $i < $count; $i++){ $tmp[] = $level[$i]; } $old_count = $count; echo "Indexes: ".implode(".", $tmp)."\n"; }
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
Indexes: 1 Indexes: 1.1 Indexes: 1.1.1 Indexes: 1.1.2 Indexes: 1.2 Indexes: 2 Indexes: 2.1 Indexes: 2.1.1 Indexes: 2.1.2 Indexes: 2.1.3 Indexes: 2.2 Indexes: 2.2.1 Indexes: 2.2.1.1
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
252.27 ms | 407 KiB | 5 Q