- Split functions and styles from index
- Start building generic log retrieval function
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
function searchForId($id, $array)
|
||||
{
|
||||
foreach ($array as $key => $val) {
|
||||
if ($val[1] == $id) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatMoney($number, $cents = 1)
|
||||
{ // cents: 0=never, 1=if needed, 2=always
|
||||
if (is_numeric($number)) { // a number
|
||||
if (!$number) { // zero
|
||||
$money = ($cents == 2 ? '0.00' : '0'); // output zero
|
||||
} else { // value
|
||||
if (floor($number) == $number) { // whole number
|
||||
$money = number_format($number, ($cents == 2 ? 2 : 0)); // format
|
||||
} else { // cents
|
||||
$money = number_format(round($number, 2), ($cents == 0 ? 0 : 2)); // format
|
||||
} // integer or decimal
|
||||
} // value
|
||||
return '$' . $money;
|
||||
} // numeric
|
||||
} // formatMoney
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user