3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ean_checksum($eancode) { if(strlen($eancode) != 12) { return '-1'; } $oddsum=0; $evensum=0; $total=0; $eanvalue=$eancode; $finalean = strrev(substr($eanvalue,0,12)); for($i=0;$i<strlen($finalean);$i++) { if(($i % 2) == 0) { $oddsum += intval($finalean[$i]); } else { $evensum += intval($finalean[$i]); } } $total=($oddsum * 3) + $evensum; $check = intval(10 - ceil($total % 10.0)) %10; return $check; } $ean = '037007923000'; echo ean_checksum($ean);
Output for git.master, git.master_jit, rfc.property-hooks
5

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:
39.49 ms | 401 KiB | 8 Q