3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function dropDownList($field_name,$array_name,$default_value,$style="",$disabled="") { session_register('$field_name'); if ($disabled == 1) $disabled = "disabled"; if ($disabled != "disabled") $disabled = ""; echo "<Select name='$field_name' ".$style." ".$disabled." >"; echo "<option value=''></option>"; for ($loop=0;$loop<count($array_name);$loop++) { echo "<option value='".$array_name[$loop]['Value']."'"; if($array_name[$loop]['Value']== $default_value) { echo " selected"; $teamMember = $array_name[$loop]['Name']; global $teamName; $teamName = $array_name[$loop]['Name']; } echo ">".$array_name[$loop]['Name']."</option>"; } echo "</select>"; } function dropNBDownList($field_name,$array_name,$default_value,$style="") { session_register('$field_name'); echo "<Select name='$field_name' ".$style." >"; for ($loop=0;$loop<count($array_name);$loop++) { echo "<option value='".$array_name[$loop]['Value']."'"; if($array_name[$loop]['Value']== $default_value) { echo " selected"; } echo ">".$array_name[$loop]['Name']."</option>"; } echo "</select>"; } function showDownList($Field_Value,$MatchArray) { $ReturnValue=""; for ($loop=0;$loop<count($MatchArray);$loop++) { if($MatchArray[$loop]['Value']==$Field_Value) { $ReturnValue=$MatchArray[$loop]['Name']; } } return $ReturnValue; } function safeDivide($tmp1,$tmp2) { if($tmp2 > 0) { $result=$tmp1/$tmp2; } else { $result=0; } return $result; } function mkcheckbox($checkvalue) { if($checkvalue == '1') { echo "checked"; } } function reimport_get_vars() { reimport_any_vars("HTTP_GET_VARS"); } function reimport_post_vars() { reimport_any_vars("HTTP_POST_VARS"); } function reimport_cookie_vars() { reimport_any_vars("HTTP_COOKIE_VARS"); } function reimport_any_vars($arrayname) { global $$arrayname; if(!is_array($$arrayname)) return; reset($$arrayname); while(list($key, $val) = each($$arrayname)) { $GLOBALS[$key] = $val; } } function do_redirect_url($url,$message="One moment please...",$delay=0) { if(SID) { if(ereg("[?]",$url)) { $url .= "&".SID; } else { $url .= "?".SID; } } if($message=="default") { $message="One moment please..."; } if($delay=="default") { $delay=0; } echo("<HTML><HEAD><META HTTP-EQUIV=\"refresh\" CONTENT=\"$delay;url=$url\"></HEAD><BODY BGCOLOR=#ffffff>$message</BODY></HTML>"); } function fieldColor($TmpStatus) { switch ($TmpStatus) { case 1: $ColorBar='#FFCCCC'; break; case 2: case 3: case 10: $ColorBar='#FFFFCC'; break; case 5: case 6: case 7: $ColorBar='#fffffe'; break; case 9: $ColorBar='#99CC99'; break; case 8: case 11: case 4: $ColorBar='#99CCFF'; break; case 12: $ColorBar='#FCE398'; break; case 13: $ColorBar='#999999'; break; } return $ColorBar; } function business_days($pickDay) { $businessDays=0; $InDays=0; list($month, $day, $year) = split('[/.-]', $pickDay); $startDay=strtotime($month."/01/".$year); $pickDay=strtotime($pickDay); $endDay=strtotime($month."/".date("t",$startDay)."/".$year); $Temp_Array=array(); $daysDiff = (date("z",$endDay) - date("z",$startDay))+1; $Week=(date("W",$pickDay)-date("W",$startDay)); while($daysDiff) { switch(date("w",$endDay)) { case 0: case 6: break; default: $businessDays++; if($endDay <= $pickDay) { $InDays++; } break; } $endDay -= (60*60*24); $daysDiff--; } $Temp_Array['Projected']=$businessDays; $Temp_Array['Days']=$InDays; $Temp_Array['Week']=$Week; // ******************* // count for holidays // ******************* if($month == 7) { $Temp_Array['Projected']=$Temp_Array['Projected']-1; if($day >5) $Temp_Array['Days']=$Temp_Array['Days']-1; } if($month ==9) { $Temp_Array['Projected']=$Temp_Array['Projected']-1; if($day >6) $Temp_Array['Days']=$Temp_Array['Days']-1; } if($month ==12) { $Temp_Array['Projected']=$Temp_Array['Projected']-1; if($day >23) $Temp_Array['Days']=$Temp_Array['Days']-1; } return $Temp_Array; } function mydate_format($datestamp){ $tzoffset = 0; if ($datestamp == "0000-00-00" || $datestamp=="0000-00-00 00:00:00" || $datestamp=="") { $sDate = ""; } else { list($date,$time) = explode(" ",$datestamp); list($year,$month,$day) = explode("-",$date); list($hour,$minute,$second) = explode(":",$time); $hour = $hour + $tzoffset; $tstamp = mktime($hour,$minute,$second,$month,$day,$year); $sDate = date("m/d/Y H:i",$tstamp); } return $sDate; } function mydateNtime_format($datestamp){ $tzoffset = 0; if ($datestamp == "0000-00-00" || $datestamp=="0000-00-00 00:00:00" || $datestamp=="") { $sDate = ""; } else { list($date,$time) = explode(" ",$datestamp); list($year,$month,$day) = explode("-",$date); list($hour,$minute,$second) = explode(":",$time); $hour = $hour + $tzoffset; $tstamp = mktime($hour,$minute,$second,$month,$day,$year); $sDate = date("m/d/Y",$tstamp); } return $sDate; } function myTime_format($datestamp){ $tzoffset = 0; if ($datestamp == "0000-00-00" || $datestamp=="0000-00-00 00:00:00" || $datestamp=="") { $sDate = ""; } else { list($date,$time) = explode(" ",$datestamp); list($year,$month,$day) = explode("-",$date); list($hour,$minute,$second) = explode(":",$time); $hour = $hour + $tzoffset; $tstamp = mktime($hour,$minute,$second,$month,$day,$year); $sDate = date("H:i",$tstamp); } return $sDate; } function MakeDate($datestamp) { if($datestamp!="") { list($month, $day, $year, $hour, $min) = split('[ :/.-]', $datestamp); //$tstamp=$year."-".$month."-".$day; if($month=="")$month=0; if($min=="")$min=0; $tstamp = mktime($hour,$min,0,$month,$day,$year); $sDate=date("Y-m-d H:i",$tstamp); } else { $sDate="0000-00-00"; } return $sDate; } function getDialerStatus() { require("./connect.php"); $SelectQuery = "SELECT statusname,statusvalue FROM statusdetail order by statusvalue "; // run query if($results = MYSQL_query($SelectQuery,$connect)) { $Tmp_Array = array(); $counter=0; while ($row = MYSQL_fetch_array($results)) { $value = $row['statusvalue']; $Tmp_Array[$value]['Name'] = $row['statusname']; $counter++; } MYSQL_close($connect); } else { MYSQL_close($connect); die("Could not connect <br>$SelectQuery"); }// end if else return $Tmp_Array; } function getDialerStatusSRMC() { require("./connectProc.php"); $SelectQuery = "SELECT name,value FROM mccallstatus order by value "; // run query if($results = MYSQL_query($SelectQuery,$connect)) { $Tmp_Array = array(); $counter=0; while ($row = MYSQL_fetch_array($results)) { $value = $row['value']; $Tmp_Array[$value]['Name'] = $row['name']; $counter++; } MYSQL_close($connect); } else { MYSQL_close($connect); die("Could not connect <br>$SelectQuery"); }// end if else return $Tmp_Array; } function convertFloat($strValue) { $floatValue = ereg_replace("(^[0-9]*)(\\.|,)([0-9]*)(.*)", "\\1,\\3", $strValue); if (!is_numeric($floatValue)) $floatValue = ereg_replace("(^[0-9]*)(.*)", "\\1", $strValue); if (!is_numeric($floatValue)) $floatValue = 0; return $floatValue; } function strtflt($str) { $il = strlen($str); $flt = ""; $cstr = ""; for($i=0;$i<$il;$i++) { $cstr = substr($str, $i, 1); if(is_numeric($cstr) || $cstr == ".") $flt = $flt.$cstr; } return floatval($flt); } ?>
Output for 5.4.0 - 7.2.0