3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urzadzenia_ilosc = 10; $zakres = '123-999'; $zakres = str_replace("-","",$zakres); echo "poczatek: ".$zakres."<br />"; $zakres_tmp = array(); for($i=0;$i<$urzadzenia_ilosc;$i++){ $zakres_tmp[] = "H-".substr($zakres, 0, 3)."-".substr($zakres, 3, 6); $zakres++; } print_r($zakres_tmp); echo count(zakres_tmp); ?>
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
poczatek: 123999<br />Array ( [0] => H-123-999 [1] => H-124-000 [2] => H-124-001 [3] => H-124-002 [4] => H-124-003 [5] => H-124-004 [6] => H-124-005 [7] => H-124-006 [8] => H-124-007 [9] => H-124-008 ) Fatal error: Uncaught Error: Undefined constant "zakres_tmp" in /in/tSjAC:14 Stack trace: #0 {main} thrown in /in/tSjAC on line 14
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
poczatek: 123999<br />Array ( [0] => H-123-999 [1] => H-124-000 [2] => H-124-001 [3] => H-124-002 [4] => H-124-003 [5] => H-124-004 [6] => H-124-005 [7] => H-124-006 [8] => H-124-007 [9] => H-124-008 ) Warning: Use of undefined constant zakres_tmp - assumed 'zakres_tmp' (this will throw an Error in a future version of PHP) in /in/tSjAC on line 14 Warning: count(): Parameter must be an array or an object that implements Countable in /in/tSjAC on line 14 1
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
poczatek: 123999<br />Array ( [0] => H-123-999 [1] => H-124-000 [2] => H-124-001 [3] => H-124-002 [4] => H-124-003 [5] => H-124-004 [6] => H-124-005 [7] => H-124-006 [8] => H-124-007 [9] => H-124-008 ) Notice: Use of undefined constant zakres_tmp - assumed 'zakres_tmp' in /in/tSjAC on line 14 1

preferences:
280.64 ms | 405 KiB | 459 Q