3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $zakres_valid = '/^[A-Za-z\/]{1,5}-[0-9]{5,8}$/'; $zakres = array(); $st = 'ST-856549'; for($i=0;$i<10;$i++){ $zakres[] = $st; $st++; } var_dump($zakres); if(!preg_match($zakres_valid, $zakres)){ echo "/".$zakres_valid.", ".$zakres."/"; echo "ERROR. Numer $zakres[$i] z podanego zakresu nie pasuje do wzorca.<br />"; } else { echo "OK"; } ?>
based on 1NHgD
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
array(10) { [0]=> string(9) "ST-856549" [1]=> string(9) "ST-856550" [2]=> string(9) "ST-856551" [3]=> string(9) "ST-856552" [4]=> string(9) "ST-856553" [5]=> string(9) "ST-856554" [6]=> string(9) "ST-856555" [7]=> string(9) "ST-856556" [8]=> string(9) "ST-856557" [9]=> string(9) "ST-856558" } Warning: preg_match() expects parameter 2 to be string, array given in /in/jhuao on line 12 Notice: Array to string conversion in /in/jhuao on line 13 //^[A-Za-z\/]{1,5}-[0-9]{5,8}$/, Array/ Notice: Undefined offset: 10 in /in/jhuao on line 14 ERROR. Numer z podanego zakresu nie pasuje do wzorca.<br />
Output for hhvm-3.12.0
array(10) { [0]=> string(9) "ST-856549" [1]=> string(9) "ST-856550" [2]=> string(9) "ST-856551" [3]=> string(9) "ST-856552" [4]=> string(9) "ST-856553" [5]=> string(9) "ST-856554" [6]=> string(9) "ST-856555" [7]=> string(9) "ST-856556" [8]=> string(9) "ST-856557" [9]=> string(9) "ST-856558" } Warning: preg_match() expects parameter 2 to be string, array given in /in/jhuao on line 12 Notice: Array to string conversion in /in/jhuao on line 13 //^[A-Za-z\/]{1,5}-[0-9]{5,8}$/, Array/ Notice: Undefined index: 10 in /in/jhuao on line 14 ERROR. Numer z podanego zakresu nie pasuje do wzorca.<br />
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.0 - 5.3.29
array(10) { [0]=> string(9) "ST-856549" [1]=> string(9) "ST-856550" [2]=> string(9) "ST-856551" [3]=> string(9) "ST-856552" [4]=> string(9) "ST-856553" [5]=> string(9) "ST-856554" [6]=> string(9) "ST-856555" [7]=> string(9) "ST-856556" [8]=> string(9) "ST-856557" [9]=> string(9) "ST-856558" } Warning: preg_match() expects parameter 2 to be string, array given in /in/jhuao on line 12 //^[A-Za-z\/]{1,5}-[0-9]{5,8}$/, Array/ Notice: Undefined offset: 10 in /in/jhuao on line 14 ERROR. Numer z podanego zakresu nie pasuje do wzorca.<br />
Output for 4.3.3 - 5.2.17
array(10) { [0]=> string(9) "ST-856549" [1]=> string(9) "ST-856550" [2]=> string(9) "ST-856551" [3]=> string(9) "ST-856552" [4]=> string(9) "ST-856553" [5]=> string(9) "ST-856554" [6]=> string(9) "ST-856555" [7]=> string(9) "ST-856556" [8]=> string(9) "ST-856557" [9]=> string(9) "ST-856558" } Warning: preg_match() expects parameter 2 to be string, array given in /in/jhuao on line 12 //^[A-Za-z\/]{1,5}-[0-9]{5,8}$/, Array/ Notice: Undefined offset: 10 in /in/jhuao on line 14 ERROR. Numer z podanego zakresu nie pasuje do wzorca.<br />
Output for 4.3.0 - 4.3.2
array(10) { [0]=> string(9) "ST-856549" [1]=> string(9) "ST-856550" [2]=> string(9) "ST-856551" [3]=> string(9) "ST-856552" [4]=> string(9) "ST-856553" [5]=> string(9) "ST-856554" [6]=> string(9) "ST-856555" [7]=> string(9) "ST-856556" [8]=> string(9) "ST-856557" [9]=> string(9) "ST-856558" } Notice: Array to string conversion in /in/jhuao on line 12 //^[A-Za-z\/]{1,5}-[0-9]{5,8}$/, Array/ Notice: Undefined offset: 10 in /in/jhuao on line 14 ERROR. Numer z podanego zakresu nie pasuje do wzorca.<br />