Source for file Functions.php
Documentation is available at Functions.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Copyright (c) 2002-2003 Brent Cook |
// | Copyright (c) 2002 The PHP Group
// +----------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
// | Authors: Jacob Lee <jacobswell4u@yahoo.com> |
// | Authors: Brent Cook <busterb@mail.utexas.edu> |
// +----------------------------------------------------------------------+
// $Id: Functions.php,v 1.1 2003/01/08 19:22:51 busterb Exp $
* functions like those in SQL
// {{{ max($field, $rows)
function max ($field, $rows)
// {{{ min($field, $rows)
function min ($field, $rows)
// {{{ sum($field, $rows)
function sum ($field, $rows)
// {{{ avg($field, $rows)
function avg ($field, $rows)
// {{{ count($field, $rows)
* Internal function for returning the current time
function in ($val, $val1, $val2, $val3 = null )
$isIn = ($val == $val1 or $val == $val2) ? true : false;
if ($val3 == null ) return $isIn;
return ($isIn or $val == $val3) ? true : false;
// {{{ between($num, $min, $max)
function between ($num, $min, $max)
if ($min == $max) return ($num == $min) ? true : false;
return ($num >= $min and $num <= $max) ? true : false;
function log ($val, $base)
// {{{ mod($val, $devider)
function mod ($val, $devider)
if ($devider == null ) return null;
return ($val > 0 ) ? 1 : (($val == 0 ) ? 0 : -1 );
// {{{ concat($str1, $str2)
function concat ($str1, $str2)
// {{{ lpad($input, $padLength, $padString)
function lpad ($input, $padLength, $padString)
return str_pad($input, $padLength, $padString, STR_PAD_LEFT );
// {{{ rpad($input, $padlength, $padString)
function rpad ($input, $padlength, $padString)
return str_pad($input, $padLength, $padString, STR_PAD_RIGHT );
// {{{ replace($str, $search, $replace = '')
function replace ($str, $search, $replace = '')
if ($search == null ) return $str;
if ($replace == null ) $replace = '';
// {{{ substring($str, $start, $length = null)
function substring ($str, $start, $length = null )
if ($start > 0 ) $start--;
return ($length == null ) ? substr($str, $start)
: substr($str, $start, $length);
// {{{ translate($str, $from, $to)
function translate ($str, $from, $to)
return PEAR ::raiseError ("needs elements that have the same string length");
for ($i = 0; $i < strlen($str); $i++ ) {
$translate .= $toWord[$fromWord[$str[$i]]];
// {{{ instr($str, $match, $start = 1, $count = 1)
function instr ($str, $match, $start = 1 , $count = 1 )
$pos = strpos($str, $match, $start);
for ($i = 1; $i != $count; $i++ ) {
$pos = strpos($str, $match, $pos+1 );
if ($pos == false ) return 0;
for ($i = 1; $i != $count; $i++ ) {
if ($pos == false ) return 0;
return PEAR ::raiseError ("invalid start number");
// {{{ strlike($str,$search,$option=0)
function strlike ($str,$search,$option=0 )
* if the value of $option is
Documentation generated on Mon, 11 Mar 2019 14:59:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|