/common.inc.php

Description

Common file containing functions which extend PHP's functionality

These functions are not involved with the database or user interaction in any way. They serve only to build upon the function base of PHP.

Functions
ampentity (line 23)

Replaces & with &

string ampentity (string $String)
  • string $String
array_change_key_case_recursive (line 93)

Recursively changes the case of all array keys

array array_change_key_case_recursive (array $arr, [integer $case = CASE_LOWER])
  • array $arr
  • integer $case
bool (line 119)

Returns a string representation of the result of a boolean evaluation of a variable.

string bool (mixed $in)
  • mixed $in
boolean_and (line 39)

Returns the logical AND of two booleans

string boolean_and (boolean $b1, boolean $b2)
  • boolean $b1
  • boolean $b2
boolean_or (line 55)

Returns the logical OR of two booleans

string boolean_or (boolean $b1, boolean $b2)
  • boolean $b1
  • boolean $b2
caplength (line 70)

Fixes a string to a certain maximum length.

string caplength (string $string, integer $length)
  • string $string
  • integer $length
concatinate (line 142)

Concatinates two strings

string concatinate (string $str1, string $str2)
  • string $str1
  • string $str2
encode (line 157)

Encodes a string as specified by $Encoding

void encode (string $String, integer $Encoding)
  • string $String
  • integer $Encoding
encoding_convert_encoding (line 200)

Converts string from one encoding to another

string encoding_convert_encoding (string $str, string $to_encoding, [string $from_encoding = 'UTF-8'])
  • string $str
  • string $to_encoding
  • string $from_encoding
encoding_strlen (line 241)

Finds length of multi-byte strings

integer encoding_strlen (string $str, [string $encoding = 'UTF-8'])
  • string $str
  • string $encoding
encoding_strpos (line 276)

Returns position of $needle as integer or false if $needle is not present in $haystack

mixed encoding_strpos (string $haystack, string $needle, [integer $offset = 0], [string $encoding = 'UTF-8'])
  • string $haystack
  • string $needle
  • integer $offset
  • string $encoding
encoding_strrpos (line 310)

Same as strpos, except finds position from end of $haystack

mixed encoding_strrpos (string $haystack, string $needle, [integer $offset = 0], [string $encoding = 'UTF-8'])
  • string $haystack
  • string $needle
  • integer $offset
  • string $encoding
encoding_strtolower (line 376)

Returns lowercase representation of string

string encoding_strtolower (string $str, [string $encoding = 'UTF-8'])
  • string $str
  • string $encoding
encoding_strtoupper (line 404)

Returns uppercase representation of string

string encoding_strtoupper (string $str, [string $encoding = 'UTF-8'])
  • string $str
  • string $encoding
encoding_substr (line 344)

Returns substring based on $start position and $length

mixed encoding_substr (string $string, integer $start, [integer $length = NULL], [string $encoding = 'UTF-8'])
  • string $string
  • integer $start
  • integer $length
  • string $encoding
encoding_substr_count (line 433)

Returns number of times $needle appears in $haystack

integer encoding_substr_count (string $haystack, string $needle, [string $encoding = 'UTF-8'])
  • string $haystack
  • string $needle
  • string $encoding
encoding_substr_replace (line 464)

Returns $string with substring replaced with $replacement

string encoding_substr_replace (string $string, string $replacement, integer $start, [integer $length = NULL], [string $encoding = 'UTF-8'])
  • string $string
  • string $replacement
  • integer $start
  • integer $length
  • string $encoding
file_get_contents_array (line 501)

Loads an array of files from one file.

This function adds a layer of abstraction when opening files in PHP. If the file passed is a supported multi-file archive, every file in that archive will be loaded into the array. If the file is a compressed file, the file will be decompressed and loaded into the array.

Even if only one file is loaded, it will be put into an array, so any code calling this function should expect an array on success.

Currently supported formats:

  • zip
  • rar
  • gz
  • bz2

array file_get_contents_array (string $Filename)
  • string $Filename
fixlength (line 574)

Fixes a string to a certain length using  's.

Similar to strpad, except the length is strict (i.e. if the string is longer than length, it will be truncated.)

string fixlength (string $string, integer $length)
  • string $string
  • integer $length
formatNumber (line 602)

Formats a floating point number to only hold the needed number of decimal points

float formatNumber (float $number)
  • float $number
formatsize (line 628)

Returns a nicely formatted string representation of a filesize.

string formatsize (integer $size)
  • integer $size
formattime (line 670)

Returns a nicely formatted string representation of a time.

string formattime (integer $time)
  • integer $time
getCSVFromString (line 713)

Parses CSV into two-dimensional array

string[][] getCSVFromString (string $string)
  • string $string
get_enabled_compression_extensions (line 780)

Returns an array of enabled compression file extensions

string[] get_enabled_compression_extensions ()
highlightcolor (line 817)

Returns a hex color for highlighting

string highlightcolor (integer $number)
  • integer $number
implode_keys (line 855)

Implodes $pieces while including keys in returned string

string implode_keys ([string $glue = NULL], array $pieces, [string $keyvalglue = NULL])
  • string $glue
  • array $pieces
  • string $keyvalglue
map_recursive (line 887)

Functions like array_map, but works also on objects and all child objects.

Note: In the case of a recursive objects (i.e. a doubly-linked list) you must pass the name of the recursive property to $ignoredproperties or your webserver will crash! $ignoredproperties should contain a comma-delimited list of object properties to ignore.

mixed map_recursive (callback $function, mixed $var, [string $ignoredproperties = 'Collection,Collections,Parent,PrimaryCreator'])
  • callback $function
  • mixed $var
  • string $ignoredproperties
natcaseksort (line 944)

Functions exactly as natcasesort, but sorts by key value

boolean natcaseksort (array &$array)
  • array &$array
nextbitmask (line 977)

Returns next bitmask of type $strBitmask. Useful when total number of required bitmasks is unknown

integer nextbitmask (string $strBitmask)
  • string $strBitmask
pluralize (line 1002)

Attempts to pluralize a string

string pluralize (string $word)
  • string $word
ptag (line 1034)

Converts line breaks to <p></p>

string ptag (string $string)
  • string $string
singularize (line 1049)

Attempts to singularize a string

string singularize (string $word)
  • string $word
unextendcharacters (line 1088)

Replates extended characters with their non-extended equivalents.

string unextendcharacters (string $string)
  • string $string

Documentation generated on Wed, 05 Mar 2008 16:45:50 -0600 by phpDocumentor 1.3.1