Location: PHPKode > projects > TheoPlan > pm/helper.inc
<?php
function str_wordcount($str, $br=".") {
	if (strlen((string)$str) == 0) {
	   return 0;
	}

	$as = explode($br, $str);
	$anz = 0;

	foreach ($as as $tk) {
	   $anz++;
	}

	return $anz;
}

function FormatNum($num, $komma) {
	$str = sprintf ("%." . $komma . "f", $num);
	$str = str_replace (".", "|", $str);
	$str = str_replace (",", ".", $str);
	$str = str_replace ("|", ",", $str);
	return $str;
}

function GetPT($periode) {
	$mon = gmdate("n", $periode);
	$year = gmdate("Y", $periode);
	$days = daysinmonth($mon, $year);
	$d = 1;
	$wd = 0;

	while ($d <= $days) {
	   $ts = gmmktime(0, 0, 0, $mon, $d, $year);
	   $dtarr = getdate($ts);
	   $wday = $dtarr["wday"];

	   if ($wday > 0 && $wday < 6)
	      $wd++;

	   $d++;
	}

	return $wd;
}

function CheckTrue($var) {
	if (!isset($var))
	   return false;

	if (is_bool($var) && $var == true)
	   return true;

	if (is_string($var) && ($var == "t" || $var == "true" || $var == "on"))
	   return true;

	if (is_numeric($var) && $var != 0)
	   return true;

	return false;
}

function GetBrowserInfo($key) {
	$browser = get_browser();

        while (list ($schl, $value) = each ($browser)) {
	   if ($schl == $key)
	      return $value;
	}

	return "";
}

function DEBUG($str) {
	$fp = fopen("/tmp/debug.txt", "a");
	$tm = date("j.n.Y H:i:s", time());
	fwrite($fp, "$tm: $str\n");
	fclose($fp);
}

?>
Return current item: TheoPlan