3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _createUniqueSkuPartFromId($configurableId){ echo 'calling ' . __FUNCTION__ . '(' . $configurableId . ')' . PHP_EOL; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charsLength = strlen($chars); $characterPart = ''; $value = $configurableId; for($i = 3; $i > 0 ; $i--) { echo PHP_EOL . '$i = ' . $i; var_dump($value); $mod = $value % $charsLength; $floordiv = $value/$charsLength; var_dump($mod, $floordiv); $characterPart = $chars {$mod} . $characterPart; $value = $floordiv; } $numberPart = str_pad(99 - ($configurableId % 100), 2, '0', STR_PAD_LEFT); echo 'done, created number part and character part that are expected to be unique ' . PHP_EOL; echo '$numberPart: ' . $numberPart . PHP_EOL; echo '$characterPart: ' . $characterPart . PHP_EOL; echo 'concated: ' . $numberPart.$characterPart.PHP_EOL . '----------------------------' . PHP_EOL; return $numberPart . $characterPart; } $range = array(100, 105); foreach ($range as $configId) { _createUniqueSkuPartFromId($configId); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/g4sPP on line 20
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/g4sPP on line 20 calling _createUniqueSkuPartFromId(100) $i = 3int(100) int(22) float(3.8461538461538) $i = 2float(3.8461538461538) int(3) float(0.14792899408284) $i = 1float(0.14792899408284) int(0) float(0.0056895766954939) done, created number part and character part that are expected to be unique $numberPart: 99 $characterPart: ADW concated: 99ADW ---------------------------- calling _createUniqueSkuPartFromId(105) $i = 3int(105) int(1) float(4.0384615384615) $i = 2float(4.0384615384615) int(4) float(0.15532544378698) $i = 1float(0.15532544378698) int(0) float(0.0059740555302685) done, created number part and character part that are expected to be unique $numberPart: 94 $characterPart: AEB concated: 94AEB ----------------------------
Output for 5.0.2 - 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.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.26
calling _createUniqueSkuPartFromId(100) $i = 3int(100) int(22) float(3.8461538461538) $i = 2float(3.8461538461538) int(3) float(0.14792899408284) $i = 1float(0.14792899408284) int(0) float(0.0056895766954939) done, created number part and character part that are expected to be unique $numberPart: 99 $characterPart: ADW concated: 99ADW ---------------------------- calling _createUniqueSkuPartFromId(105) $i = 3int(105) int(1) float(4.0384615384615) $i = 2float(4.0384615384615) int(4) float(0.15532544378698) $i = 1float(0.15532544378698) int(0) float(0.0059740555302685) done, created number part and character part that are expected to be unique $numberPart: 94 $characterPart: AEB concated: 94AEB ----------------------------
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 5 calling _createUniqueSkuPartFromId(100)PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 3int(100) int(22) float(3.8461538461538) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 2float(3.8461538461538) int(3) float(0.14792899408284) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 1float(0.14792899408284) int(0) float(0.0056895766954939) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 26 done, created number part and character part that are expected to be unique PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 27 $numberPart: 99PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 28 $characterPart: ADWPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 concated: 99ADWPHP_EOL----------------------------PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 5 calling _createUniqueSkuPartFromId(105)PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 3int(105) int(1) float(4.0384615384615) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 2float(4.0384615384615) int(4) float(0.15532544378698) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 1float(0.15532544378698) int(0) float(0.0059740555302685) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 26 done, created number part and character part that are expected to be unique PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 27 $numberPart: 94PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 28 $characterPart: AEBPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 concated: 94AEBPHP_EOL----------------------------PHP_EOL
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9
calling _createuniqueskupartfromid(100) $i = 3int(100) int(22) float(3.8461538461538) $i = 2float(3.8461538461538) int(3) float(0.14792899408284) $i = 1float(0.14792899408284) int(0) float(0.0056895766954939) done, created number part and character part that are expected to be unique $numberPart: 99 $characterPart: ADW concated: 99ADW ---------------------------- calling _createuniqueskupartfromid(105) $i = 3int(105) int(1) float(4.0384615384615) $i = 2float(4.0384615384615) int(4) float(0.15532544378698) $i = 1float(0.15532544378698) int(0) float(0.0059740555302685) done, created number part and character part that are expected to be unique $numberPart: 94 $characterPart: AEB concated: 94AEB ----------------------------
Output for 4.3.0 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 5 calling _createuniqueskupartfromid(100)PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 3int(100) int(22) float(3.8461538461538) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 2float(3.8461538461538) int(3) float(0.14792899408284) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 1float(0.14792899408284) int(0) float(0.0056895766954939) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 26 done, created number part and character part that are expected to be unique PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 27 $numberPart: 99PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 28 $characterPart: ADWPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 concated: 99ADWPHP_EOL----------------------------PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 5 calling _createuniqueskupartfromid(105)PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 3int(105) int(1) float(4.0384615384615) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 2float(4.0384615384615) int(4) float(0.15532544378698) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 12 PHP_EOL$i = 1float(0.15532544378698) int(0) float(0.0059740555302685) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 26 done, created number part and character part that are expected to be unique PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 27 $numberPart: 94PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 28 $characterPart: AEBPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g4sPP on line 29 concated: 94AEBPHP_EOL----------------------------PHP_EOL

preferences:
281.63 ms | 409 KiB | 354 Q