Location: PHPKode > scripts > Small Business Break-Even Analyzer > small-business-break-even-analyzer/sbbe_files/functions.php
<?php
	
	function costFormat($num,$nodecimals=0) {
		if ($nodecimals == 1) {
			$decimals = 0;
		} else {
			$decimals = 2;
		}
		return number_format($num,$decimals,'.',',');
	}
	
	
	function ternary($current,$item1,$item2) {
		if ($current == $item1) {
			return $item2;
		} else {
			return $item1;
		}
	}
	
	function getResultDiv($value,$type='error') {
		// Formats successful or error results whether they are in an array or a snippet.
		if ($type == 'success') {
			$class = 'success-div';
		} elseif ($type == 'test') {
			$class = 'test-div';
		} else {
			$class = 'error-div';
		}
		if (is_array($value)) {
			for ($i = 0; $value[$i] != ''; $i++) {
				$result_div .= '<li>' . $value[$i] . '</li>';
			}
			if ($result_div != '') {
				$result_div = '<div class="' . $class . '"><ul>' . $result_div . '</ul></div>';
			}
		} else {
			if ($value != '') {
				$result_div = '<div class="' . $class . '">' . $value . '</div>';
			}
		}
		return $result_div;
	}
	
	function checkValidChars($string,$valid_chars) {
		$string_array = str_split($string);
		$valid_chars_array = str_split($valid_chars);
		$i = 0;
		while ($string_array[$i] != '') {
			if (!in_array($string_array[$i],$valid_chars_array)) {
				return false;
			}
			$i++;
		}
		return true;
	}
	
	if (!function_exists('str_split')) {
		function str_split($string, $split_length = 1) {
			return explode("\r\n", chunk_split($string, $split_length));
		}
	}
?>
Return current item: Small Business Break-Even Analyzer