access.inc.php

ian – Thu, 2006 – 08 – 24 23:58

<?php

/* Access emulation functions * Note that many of these functions aren't exactly the same as what's in Access. They were enough to work for my conversion project. * Copyright (C) 2006 Ian Howson * http://www.mouldy.org */ function vbaSwitch()
{
$args = func_get_args();
$state = 0;

foreach ($args as $a) {
switch ($state) {
case 0: // check this condition
if ($a)
$state = 1;
else
$state = 2;

break;
case 1: // return this expression
return $a;
$state = 0;
break;
case 2: // skip this expression
$state = 0;
break;
}
}
return null;
}

function nz($var, $default = "")
{
if ($var == null)
return $default;
else
return $var;
}

function FormatCurrency($value, $decplaces)
{
// Can't just use money_format, since that's not supported on Windows
return '$'.number_format($value, $decplaces);
}

function FormatNumber()
{
$args = func_get_args();
return call_user_func_array('number_format', $args);
}

function IIf($cond, $true, $false)
{
if ($cond)
return $true;
else
return $false;
}

function Between($expr, $lim1, $lim2)
{
return ($expr <= $lim1 && $expr >= $lim2) || ($expr >= $lim1 && $expr <= $lim2);
}

function Left($str, $num)
{
return substr($str, 0, $num);
}

function Right($str, $num)
{
return substr($str, -$num);
}

function Len($str)
{
return strlen($str);
}

function Mid($str, $start, $length)
{
return substr($str, $start, $length);
}

function Replace($expr, $find, $replace)
{
return str_replace($find, $replace, $expr);
}


Post new comment

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
More information about formatting options