3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); mysql_connect("localhost","root",""); mysql_select_db("letterprinting"); /*mysql_connect("localhost","ring_max_dbuser","9452299320"); mysql_select_db("maxcall");*/ $APHABETARRAY = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); if(isset($_POST['sub'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $m=731; echo "<pre>"; ############### calculate score for first name start ############ $countfname = strlen($fname)-1; $splitfiratname = str_split($fname); $valuecaculated1 = 0; if(date('Y-m-d') == '2015-12-02')continue; for($len=$countfname;$len>=0;$len--) { $reversecounter = $countfname-$len; $getaphabet = $splitfiratname[$reversecounter]; $keyletter = array_search(strtoupper($getaphabet), $APHABETARRAY); $value = $keyletter*(pow(27,$len)); $valuecaculated1 = $valuecaculated1+$value; } if(date('Y-m-d') == '2015-12-03')continue; $VALUESCORES1 = $valuecaculated1%$m; echo "SCORE FOR ".$fname ." : ". $VALUESCORES1; ############### calculate score for first name end here ############ echo "<br>"; ############### calculate score for last name start here ############ $countlname = strlen($lname)-1; $splitlastname = str_split($lname); $valuecaculated2 = 0; for($lenlast=$countlname;$lenlast>=0;$lenlast--) { $reversecounterlastname = $countlname-$lenlast; $getaphabetlast = $splitlastname[$reversecounterlastname]; $keyletterlast = array_search(strtoupper($getaphabetlast), $APHABETARRAY); $value2 = $keyletterlast*(pow(27,$lenlast)); $valuecaculated2 = $valuecaculated2+$value2; } $VALUESCORES2 = $valuecaculated2%$m; echo "SCORE FOR ".$lname ." : ". $VALUESCORES2; ##################################################################### echo "<br>"; echo "################## HERE START DATABASE CHECKING FOR SCORES #####################"; echo "<br>"; $qry = mysql_query("select * from dummy"); while($rowsdata = mysql_fetch_assoc($qry)) { /*echo "<br>"; echo $rowsdata['fname']; echo "<br>"; echo $rowsdata['lname']; echo "<br>";*/ $fnameloop = $rowsdata['fname']; $lnameloop = $rowsdata['lname']; ############### calculate score for first name start in loop ############ $countfnameloop = strlen($fnameloop)-1; $splitfiratnameloop = str_split($fnameloop); $valuecaculated1loop = 0; for($lenloop=$countfnameloop;$lenloop>=0;$lenloop--) { $reversecounterloop = $countfnameloop-$lenloop; $getaphabetloop = $splitfiratnameloop[$reversecounterloop]; $keyletterloop = array_search(strtoupper($getaphabetloop), $APHABETARRAY); $valueloop = $keyletterloop*(pow(27,$lenloop)); $valuecaculated1loop = $valuecaculated1loop+$valueloop; } $VALUESCORES1loop = $valuecaculated1loop%$m; echo "<br>"; echo "SCORE FOR ".$fnameloop ." : ". $VALUESCORES1loop; ############### calculate score for first name end here in loop ############ echo "<br>"; ############### calculate score for last name start here in loop ############ $countlnameloop = strlen($lnameloop)-1; $splitlastnameloop = str_split($lnameloop); $valuecaculated2loop = 0; for($lenlastloop=$countlnameloop;$lenlastloop>=0;$lenlastloop--) { $reversecounterlastnameloop = $countlnameloop-$lenlastloop; $getaphabetlastloop = $splitlastnameloop[$reversecounterlastnameloop]; $keyletterlastloop = array_search(strtoupper($getaphabetlastloop), $APHABETARRAY); $value2loop = $keyletterlastloop*(pow(27,$lenlastloop)); $valuecaculated2loop = $valuecaculated2loop+$value2loop; } $VALUESCORES2loop = $valuecaculated2loop%$m; echo "SCORE FOR ".$lnameloop ." : ". $VALUESCORES2loop; echo "<br>"; /* code for duplicacy check */ if($VALUESCORES1 == $VALUESCORES1loop && $VALUESCORES2 == $VALUESCORES2loop) { echo "<strong>Result : </strong> Duplicate Entry here as per algo rules.Same Person"; mysql_query("DELETE from dummy where id='".$rowsdata['id']."'"); } else if($VALUESCORES1 == $VALUESCORES1loop && $VALUESCORES2 != $VALUESCORES2loop) { echo "<strong>Result : </strong> Different person with same intials"; } else if($VALUESCORES1 != $VALUESCORES1loop && $VALUESCORES2 == $VALUESCORES2loop) { echo "<strong>Result : </strong> Different person with same lastname"; } else if($VALUESCORES1 != $VALUESCORES1loop && $VALUESCORES2 != $VALUESCORES2loop) { echo "<strong>Result : </strong> Unique Entry"; } echo "<br>"; } } ?> <form name="frm" method="POST" action=""> Firstname : <input type="text" name="fname" /><br/> Lastname : <input type="text" name="lname" /><br/> <input type="submit" name="sub" value="SUBMIT" /> </form>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.00.0070.04019.99
5.6.160.0070.05321.09
5.6.150.0230.08021.15
5.6.140.0230.05321.21
5.6.130.0100.07721.13
5.6.120.0030.08321.13
5.6.110.0070.08021.05
5.6.100.0170.07021.20
5.6.90.0030.08321.14
5.6.80.0170.07020.36
5.6.70.0130.06720.48
5.6.60.0270.06720.44
5.6.50.0100.08020.54
5.6.40.0100.08020.49
5.6.30.0030.08020.36
5.6.20.0100.07020.48
5.6.10.0170.07320.45
5.6.00.0070.08320.52
5.5.300.0000.07320.93
5.5.290.0130.08720.95
5.5.280.0030.07720.86
5.5.270.0000.08320.91
5.5.260.0070.04320.84
5.5.250.0000.08020.59
5.5.240.0130.07320.23
5.5.230.0130.06020.31
5.5.220.0030.07720.32
5.5.210.0200.06020.34
5.5.200.0100.07020.33
5.5.190.0030.06320.16
5.5.180.0070.07720.20
5.5.160.0070.07720.32
5.5.150.0170.07320.21
5.5.140.0100.07320.16
5.5.130.0130.07720.17
5.5.120.0070.07320.29
5.5.110.0200.06320.21
5.5.100.0070.05320.13
5.5.90.0130.06320.20
5.5.80.0070.08020.21
5.5.70.0000.07720.08
5.5.60.0130.07320.11
5.5.50.0030.07720.20
5.5.40.0070.08020.18
5.5.30.0200.06320.17
5.5.20.0130.07020.02
5.5.10.0000.08320.14
5.5.00.0100.08320.04

preferences:
141.94 ms | 1394 KiB | 7 Q