3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('WEIGHTS', [7, 3, 1]); define('WEIGHTS_COUNT', count(WEIGHTS)); $customerNumber = 1; $invoiceNumber = 25; $refBase = sprintf('%d%04d', $customerNumber, $invoiceNumber); $weightedSum = array_reduce( array_reverse(str_split($refBase)), function($result, $v) { static $i; $i ??= 0; return $result + ($v * WEIGHTS[$i++ % WEIGHTS_COUNT]); }, 0 ); echo $refBase . (ceil($weightedSum / 10) * 10 - $weightedSum);
Output for git.master, git.master_jit, rfc.property-hooks
100256

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
31.75 ms | 405 KiB | 5 Q