3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToFarsi($matches) { $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "."); $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."); $out = ''; if (isset($matches[1])) { return str_replace($english_array, $farsi_array, $matches[1]); } return $matches[0]; } function farsi_num($num,$fake = null,$fake2=null) { return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'convertToFarsi', $num); } define("_JDF_USE_PERSIANNUM","0"); define("_JDF_TZhours","0"); define("_JDF_TZminute","0"); define('_JDF_AM_LONG','قبل از ظهر'); define('_JDF_PM_LONG','بعد از ظهر'); define('_JDF_AM_SHORT','ق.ظ'); define('_JDF_PM_SHORT','ب.ظ'); define('_JDF_Sat_LONG','شنبه'); define('_JDF_Sun_LONG','یکشنبه'); define('_JDF_Mon_LONG','دوشنبه'); define('_JDF_Tue_LONG','سه شنبه'); define('_JDF_Wed_LONG','چهارشنبه'); define('_JDF_Thu_LONG','پنجشنبه'); define('_JDF_Fri_LONG','جمعه'); define('_JDF_Sat_SHORT','ش'); define('_JDF_Sun_SHORT','ی'); define('_JDF_Mon_SHORT','د'); define('_JDF_Tue_SHORT','س'); define('_JDF_Wed_SHORT','چ'); define('_JDF_Thu_SHORT','پ'); define('_JDF_Fri_SHORT','ج'); define('_JDF_Suffix','م'); define('_JDF_Far','فروردین'); define('_JDF_Ord','اردیبهشت'); define('_JDF_Kho','خرداد'); define('_JDF_Tir','تیر'); define('_JDF_Mor','مرداد'); define('_JDF_Sha','شهریور'); define('_JDF_Meh','مهر'); define('_JDF_Aba','آبان'); define('_JDF_Aza','آذر'); define('_JDF_Dey','دی'); define('_JDF_Bah','بهمن'); define('_JDF_Esf','اسفند'); define('_JDF_Num0','?'); define('_JDF_Num1','?'); define('_JDF_Num2','?'); define('_JDF_Num3','?'); define('_JDF_Num4','?'); define('_JDF_Num5','?'); define('_JDF_Num6','?'); define('_JDF_Num7','?'); define('_JDF_Num8','?'); define('_JDF_Num9','?'); $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); $j_month_name = array("", "فروردین", "اردیبهشت", "خرداد", "تیر","مرداد", "شهریور", "مهر", "آبان", "آذر","دی", "بهمن", "اسفند"); $j_day_name = array("یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه"); $jday_abbrev = array("ی","د","س","چ","پ","ج","ش"); function div($a, $b) { return (int) ($a / $b); } function jalali_to_gregorian($j_y, $j_m, $j_d) { global $g_days_in_month; global $j_days_in_month; $jy = $j_y-979; $jm = $j_m-1; $jd = $j_d-1; $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4); for ($i=0; $i < $jm; ++$i) $j_day_no += $j_days_in_month[$i]; $j_day_no += $jd; $g_day_no = $j_day_no+79; $gy = 1600 + 400*div($g_day_no, 146097); $g_day_no = $g_day_no % 146097; $leap = true; if ($g_day_no >= 36525) { $g_day_no--; $gy += 100*div($g_day_no, 36524); $g_day_no = $g_day_no % 36524; if ($g_day_no >= 365) $g_day_no++; else $leap = false; } $gy += 4*div($g_day_no, 1461); $g_day_no %= 1461; if ($g_day_no >= 366) { $leap = false; $g_day_no--; $gy += div($g_day_no, 365); $g_day_no = $g_day_no % 365; } for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++) $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap); $gm = $i+1; $gd = $g_day_no+1; return array($gy, $gm, $gd); } function jcheckdate($j_m, $j_d, $j_y) { global $j_days_in_month; if ($j_y < 0 || $j_y > 32767 || $j_m < 1 || $j_m > 12 || $j_d < 1 || $j_d > ($j_days_in_month[$j_m-1] + ($j_m == 12 && !(($j_y-979)%33%4)))) return false; return true; } function gregorian_week_day($g_y, $g_m, $g_d) { global $g_days_in_month; $gy = $g_y-1600; $gm = $g_m-1; $gd = $g_d-1; $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400); for ($i=0; $i < $gm; ++$i) $g_day_no += $g_days_in_month[$i]; if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))) /* leap and after Feb */ ++$g_day_no; $g_day_no += $gd; return ($g_day_no + 5) % 7 + 1; } function jalali_week_day($j_y, $j_m, $j_d) { global $j_days_in_month; $jy = $j_y-979; $jm = $j_m-1; $jd = $j_d-1; $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4); for ($i=0; $i < $jm; ++$i) $j_day_no += $j_days_in_month[$i]; $j_day_no += $jd; return ($j_day_no + 2) % 7 + 1; } function gregorian_to_jalali($g_y, $g_m, $g_d) { global $g_days_in_month; global $j_days_in_month; $gy = $g_y-1600; $gm = $g_m-1; $gd = $g_d-1; $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400); for ($i=0; $i < $gm; ++$i) $g_day_no += $g_days_in_month[$i]; if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))) ++$g_day_no; $g_day_no += $gd; $j_day_no = $g_day_no-79; $j_np = div($j_day_no, 12053); $j_day_no %= 12053; $jy = 979+33*$j_np+4*div($j_day_no,1461); $j_day_no %= 1461; if ($j_day_no >= 366) { $jy += div($j_day_no-1, 365); $j_day_no = ($j_day_no-1)%365; } for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) { $j_day_no -= $j_days_in_month[$i]; } $jm = $i+1; $jd = $j_day_no+1; return array($jy, $jm, $jd); } function jdate($type,$maket="now",$forcelatinnums=false) { if (strlen($type) != 1 ){ $result=""; if($maket=="now"){ $year=date("Y"); $month=date("m"); $day=date("d"); list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $maket=jmaketime(date("h")+_JDF_TZhours,date("i")+_JDF_TZminute,date("s"),$jmonth,$jday,$jyear); }else{ $maket+=_JDF_TZhours*3600+_JDF_TZminute*60; $date=date("Y-m-d",$maket); list( $year, $month, $day ) = preg_split ( '/-/', $date ); list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); } $need= $maket; $year=date("Y",$need); $month=date("m",$need); $day=date("d",$need); $i=0; $skipnext = false; while($i<strlen($type)) { $subtype=substr($type,$i,1); if ($skipnext) { $result .= $subtype; $skipnext = false; $i++; continue; } switch ($subtype) { case "A": $result1=date("a",$need); if($result1=="pm") $result.=_JDF_PM_LONG; else $result.=_JDF_AM_LONG; break; case "a": $result1=date("a",$need); if($result1=="pm") $result.=_JDF_PM_SHORT; else $result.=_JDF_AM_SHORT; break; case "d": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result1=$jday; $result.=$result1; break; case "D": $result1=date("D",$need); if($result1=="Sat") $result1=_JDF_Sat_SHORT; else if($result1=="Sun") $result1=_JDF_Sun_SHORT; else if($result1=="Mon") $result1=_JDF_Mon_SHORT; else if($result1=="Tue") $result1=_JDF_Tue_SHORT; else if($result1=="Wed") $result1=_JDF_Wed_SHORT; else if($result1=="Thu") $result1=_JDF_Thu_SHORT; else if($result1=="Fri") $result1=_JDF_Fri_SHORT; $result.=$result1; break; case"F": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result.=monthname($jmonth); break; case "g": $result1=date("g",$need); $result.=$result1; break; case "G": $result1=date("G",$need); $result.=$result1; break; case "h": $result1=date("h",$need); $result.=$result1; break; case "H": $result1=date("H",$need); $result.=$result1; break; case "i": $result1=date("i",$need); $result.=$result1; break; case "j": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result1=$jday; $result.=$result1; break; case "l": $result1=date("l",$need); if($result1=="Saturday") $result1=_JDF_Sat_LONG; else if($result1=="Sunday") $result1=_JDF_Sun_LONG; else if($result1=="Monday") $result1=_JDF_Mon_LONG; else if($result1=="Tuesday") $result1=_JDF_Tue_LONG; else if($result1=="Wednesday") $result1=_JDF_Wed_LONG; else if($result1=="Thursday") $result1=_JDF_Thu_LONG; else if($result1=="Friday") $result1=_JDF_Fri_LONG; $result.=$result1; break; case "m": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); if($jmonth<10) $result1="0".$jmonth; else $result1=$jmonth; $result.=$result1; break; case "M": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result.=monthname($jmonth); break; case "n": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result1=$jmonth; $result.=$result1; break; case "s": $result1=date("s",$need); $result.=$result1; break; case "S": $result.=_JDF_Suffix; break; case "t": $result.=lastday ($month,$day,$year); break; case "w": $result1=date("w",$need); $result.=$result1; break; case "y": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result1=substr($jyear,2,4); $result.=$result1; break; case "Y": list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $result1=$jyear; $result.=$result1; break; case "\\": $result.=''; $skipnext = true; break; default: $result.=$subtype; } $i++; } $mps_jd_farsinum_date = "on"; $result = farsi_num($result); }else{ if ($maket == 'now'){ $result = date($type); }else{ $result = date($type,$maket); } } return $result; } function jmaketime($hour,$minute,$second,$jmonth,$jday,$jyear) { list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, $jday); $i=mktime((int) $hour,(int) $minute,(int) $second, (int) $month, (int) $day, (int) $year, 0); return $i; } function mstart($month,$day,$year) { list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, "1"); $timestamp=mktime(0,0,0,$month,$day,$year); return date("w",$timestamp); } function lastday ($month,$day,$year) { $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year)); list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day); $lastdatep=$jday; $jday=$jday2; while($jday2!="1") { if($day<$lastdayen) { $day++; list( $jyear, $jmonth, $jday2 ) = gregorian_to_jalali($year, $month, $day); if($jdate2=="1") break; if($jdate2!="1") $lastdatep++; } else { $day=0; $month++; if($month==13) { $month="1"; $year++; } } } return $lastdatep-1; } function monthname($month) { $month_map = array(1 => _JDF_Far, 2 => _JDF_Ord, 3 => _JDF_Kho, 4 => _JDF_Tir , 5 => _JDF_Mor, 6 => _JDF_Sha, 7 => _JDF_Meh, 8 => _JDF_Aba, 9 => _JDF_Aza , 10 => _JDF_Dey, 11 => _JDF_Bah, 12 => _JDF_Esf); return $month_map[(int) $month]; } ?>

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)
8.3.60.0080.01218.30
8.3.50.0080.01121.98
8.3.40.0120.00318.91
8.3.30.0110.00418.93
8.3.20.0040.00420.46
8.3.10.0030.00922.03
8.3.00.0080.00019.29
8.2.180.0170.00318.42
8.2.170.0120.00322.96
8.2.160.0140.00722.31
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0060.00326.16
8.2.120.0000.00821.04
8.2.110.0090.00020.54
8.2.100.0040.00817.91
8.2.90.0060.00318.16
8.2.80.0060.00317.97
8.2.70.0000.00918.05
8.2.60.0080.00018.28
8.2.50.0050.00319.50
8.2.40.0060.00321.07
8.2.30.0000.00919.42
8.2.20.0050.00517.86
8.2.10.0040.00418.29
8.2.00.0030.00517.73
8.1.280.0000.01525.92
8.1.270.0050.00319.02
8.1.260.0050.00326.35
8.1.250.0030.00728.09
8.1.240.0120.00922.34
8.1.230.0090.00322.81
8.1.220.0000.00817.91
8.1.210.0040.00718.90
8.1.200.0000.01017.38
8.1.190.0040.00417.47
8.1.180.0030.00719.29
8.1.170.0000.00918.71
8.1.160.0050.00219.23
8.1.150.0050.00319.01
8.1.140.0000.00817.66
8.1.130.0050.00217.97
8.1.120.0020.00517.63
8.1.110.0030.00517.65
8.1.100.0000.00717.63
8.1.90.0040.00417.52
8.1.80.0040.00417.66
8.1.70.0000.00717.63
8.1.60.0060.00317.74
8.1.50.0000.00817.64
8.1.40.0000.00917.55
8.1.30.0000.00917.82
8.1.20.0080.00017.73
8.1.10.0050.00317.69
8.1.00.0040.00417.65
8.0.300.0000.00820.16
8.0.290.0070.00316.88
8.0.280.0000.00818.61
8.0.270.0040.00417.36
8.0.260.0030.00317.42
8.0.250.0040.00417.03
8.0.240.0000.00717.11
8.0.230.0050.00217.14
8.0.220.0040.00417.14
8.0.210.0040.00417.02
8.0.200.0000.00717.01
8.0.190.0050.00317.07
8.0.180.0080.00017.10
8.0.170.0000.00817.07
8.0.160.0070.00017.05
8.0.150.0000.00716.98
8.0.140.0000.00817.08
8.0.130.0000.00813.48
8.0.120.0040.00417.04
8.0.110.0040.00416.98
8.0.100.0000.00816.93
8.0.90.0050.00317.18
8.0.80.0090.00617.03
8.0.70.0080.00017.10
8.0.60.0040.00416.93
8.0.50.0040.00416.88
8.0.30.0140.01116.99
8.0.20.0050.01717.40
8.0.10.0000.00817.13
8.0.00.0130.00516.92
7.4.330.0050.00015.03
7.4.320.0000.00616.70
7.4.300.0030.00316.77
7.4.290.0040.00416.68
7.4.280.0040.00416.75
7.4.270.0070.00016.77
7.4.260.0040.00416.77
7.4.250.0000.00916.72
7.4.240.0010.00616.73
7.4.230.0040.00416.60
7.4.220.0030.01616.64
7.4.210.0130.00916.73
7.4.200.0040.00416.55
7.4.160.0120.00416.53
7.4.150.0140.01417.40
7.4.140.0130.00817.86
7.4.130.0120.00816.55
7.4.120.0140.00816.70
7.4.110.0120.01216.61
7.4.100.0070.01016.78
7.4.90.0070.01116.69
7.4.80.0130.01019.39
7.4.70.0130.00916.57
7.4.60.0060.01216.46
7.4.50.0060.00316.64
7.4.40.0110.00716.71
7.4.30.0070.01716.55
7.4.00.0040.00815.28
7.3.330.0060.00013.38
7.3.320.0000.00713.35
7.3.310.0070.00016.32
7.3.300.0000.00816.38
7.3.290.0070.00816.44
7.3.280.0080.00716.39
7.3.270.0120.00617.40
7.3.260.0140.00416.40
7.3.250.0120.00616.48
7.3.240.0090.01316.50
7.3.230.0120.01216.60
7.3.210.0070.01116.41
7.3.200.0040.01416.79
7.3.190.0030.01316.39
7.3.180.0000.01916.38
7.3.170.0100.01016.39
7.3.160.0130.00316.42
7.3.120.0060.00914.88
7.3.110.0050.01214.75
7.3.100.0020.01214.72
7.3.90.0060.01114.83
7.3.80.0020.00914.87
7.3.70.0060.00714.90
7.3.60.0100.00615.07
7.3.50.0030.01214.66
7.3.40.0050.00714.53
7.3.30.0050.00914.93
7.3.20.0100.00616.44
7.3.10.0050.01016.36
7.3.00.0090.00716.35
7.2.330.0070.01716.60
7.2.320.0100.01016.73
7.2.310.0060.01616.46
7.2.300.0060.01316.63
7.2.290.0120.01216.78
7.2.240.0020.00915.15
7.2.230.0060.00914.96
7.2.220.0040.01115.10
7.2.210.0050.00915.11
7.2.200.0090.00915.09
7.2.190.0020.01015.07
7.2.180.0090.00815.05
7.2.170.0040.01414.91
7.2.160.0090.00614.97
7.2.150.0090.00416.83
7.2.140.0060.00816.79
7.2.130.0090.00616.63
7.2.120.0050.00716.54
7.2.110.0050.01116.65
7.2.100.0060.01116.75
7.2.90.0070.00816.82
7.2.80.0040.01516.64
7.2.70.0050.01316.70
7.2.60.0050.01016.74
7.2.50.0070.00716.82
7.2.40.0070.00916.34
7.2.30.0080.01116.60
7.2.20.0060.01216.77
7.2.10.0080.00816.62
7.2.00.0010.01417.39
7.1.330.0090.00415.64
7.1.320.0070.00515.48
7.1.310.0050.00915.78
7.1.300.0050.00915.73
7.1.290.0060.00815.63
7.1.280.0040.00915.57
7.1.270.0000.01215.63
7.1.260.0030.01215.49
7.1.250.0090.00915.75
7.1.200.0000.00915.78
7.1.100.0040.00817.62
7.1.70.0040.01116.54
7.1.60.0100.01619.22
7.1.50.0030.01716.66
7.1.00.0100.06722.37
7.0.200.0080.00416.34
7.0.140.0100.06321.95
7.0.100.0100.08321.79
7.0.90.0070.07021.73
7.0.80.0100.08021.66
7.0.70.0130.07321.66
7.0.60.0030.08721.88
7.0.50.0070.08022.02
7.0.40.0070.08320.10
7.0.30.0030.06720.13
7.0.20.0100.05020.04
7.0.10.0030.08720.05
7.0.00.0170.07020.15
5.6.280.0030.07721.25
5.6.250.0030.05020.73
5.6.240.0100.07320.76
5.6.230.0230.05020.64
5.6.220.0100.07320.75
5.6.210.0130.07720.79
5.6.200.0070.08321.16
5.6.190.0030.08321.07
5.6.180.0100.08321.07
5.6.170.0070.05321.16
5.6.160.0070.06021.27
5.6.150.0000.08721.06
5.6.140.0000.05721.17
5.6.130.0070.08721.01
5.6.120.0100.08721.17
5.6.110.0000.05721.20
5.6.100.0170.06721.13
5.6.90.0100.08021.13
5.6.80.0030.08720.56
5.6.70.0070.08720.59
5.6.60.0070.06320.46
5.6.50.0100.07320.42
5.6.40.0130.07020.48
5.6.30.0100.06720.50
5.6.20.0070.07320.57
5.6.10.0100.08020.59
5.6.00.0070.08020.58
5.5.380.0070.07320.52
5.5.370.0000.04720.59
5.5.360.0030.06720.55
5.5.350.0000.08020.59
5.5.340.0130.07320.96
5.5.330.0000.06721.01
5.5.320.0030.08020.93
5.5.310.0100.06020.86
5.5.300.0070.07321.01
5.5.290.0130.05321.04
5.5.280.0200.06320.99
5.5.270.0030.08321.03
5.5.260.0170.07320.90
5.5.250.0000.05020.74
5.5.240.0030.08020.39
5.5.230.0100.07320.30
5.5.220.0070.08020.30
5.5.210.0070.06020.24
5.5.200.0170.08320.40
5.5.190.0100.04720.41
5.5.180.0100.06020.26
5.5.160.0100.07320.26
5.5.150.0100.07720.41
5.5.140.0130.06720.28
5.5.130.0100.06020.28
5.5.120.0100.07020.31
5.5.110.0030.08720.40
5.5.100.0100.08720.14
5.5.90.0100.07720.30
5.5.80.0070.06020.23
5.5.70.0070.06020.23
5.5.60.0000.04720.16
5.5.50.0070.07320.27
5.5.40.0130.05320.27
5.5.30.0130.07320.18
5.5.20.0130.07720.28
5.5.10.0000.04320.21
5.5.00.0100.07020.20
5.4.450.0030.04319.50
5.4.440.0100.08019.56
5.4.430.0070.06719.28
5.4.420.0000.08319.57
5.4.410.0030.08019.09
5.4.400.0030.07318.96
5.4.390.0070.07019.12
5.4.380.0070.08019.25
5.4.370.0070.04319.09
5.4.360.0030.06319.28
5.4.350.0070.07719.14
5.4.340.0130.04019.28
5.4.320.0030.05019.12
5.4.310.0030.07319.08
5.4.300.0070.07019.17
5.4.290.0030.08019.01
5.4.280.0030.08019.25
5.4.270.0170.06319.09
5.4.260.0100.07319.17
5.4.250.0030.07718.95
5.4.240.0030.08019.04
5.4.230.0170.06318.89
5.4.220.0030.07718.94
5.4.210.0000.08319.09
5.4.200.0100.07319.07
5.4.190.0030.07719.09
5.4.180.0030.05019.27
5.4.170.0030.08019.09
5.4.160.0100.03719.11
5.4.150.0130.06719.07
5.4.140.0070.07716.46
5.4.130.0070.06716.51
5.4.120.0130.03716.49
5.4.110.0070.07016.39
5.4.100.0030.08316.41
5.4.90.0100.06316.46
5.4.80.0030.07316.41
5.4.70.0030.07716.58
5.4.60.0000.04016.54
5.4.50.0100.06316.46
5.4.40.0070.05016.43
5.4.30.0070.07016.43
5.4.20.0100.07016.38
5.4.10.0000.05016.46
5.4.00.0070.07016.05

preferences:
32.84 ms | 401 KiB | 5 Q