/php/lib/util.php

Description

Utility funcs.

Functions
array_order_by (line 198)

Sort a two dimensional array based on a 'column' key

  • return: the original array on argument errors, the sorted array on success
array array_order_by (array &$array, [mixed $key = null], [mixed $order = null], [bool $retain_keys = TRUE], [bool $case_sensitive = FALSE])
  • array $array: the array to be sorted
  • mixed $key: the column key to be used for sorting, an array of keys are also acceptable
  • mixed $order: the order of the sort, either 'asc' (ascending) or 'desc' (descending), can also be an array (with matching array keys to the $key param)
  • bool $retain_keys: option to retain the original keys; default to true
  • bool $case_sensitive: option for a case sensitive sort; default to false
debug_r (line 98)

Print out an varible enclosed by <pre> tags

void debug_r (mixed &$var)
  • mixed $var: the variable to print by print_r
emptify_in_array (line 131)

This recursive function empty values in an 'multi-dimensional' array.

  • return: false if an empty needle passed in, else a copy of the array with needle values replaced with empty strings
mixed emptify_in_array (mixed $array, mixed $needle)
  • mixed $needle: it accepts just one value or an array of values
microtime_float (line 12)

determine float value of now

  • return: value of current time in seconds
float microtime_float ()
password_gen (line 110)

Generate a random string good for passwords

  • return: password
string password_gen ([in $len = 6])
  • in $len: the length of the password string
record_exists (line 158)

This function checks for the existence of a particular row in a particular table matching a value.

Use this with libdb, unless you want lots of problems. :)

void record_exists (string $table, string $column, string $val, [string $extra = NULL])
  • string $table: name of table
  • string $column: name of column containing value to match
  • string $val: value to match against database (goes in WHERE clause)
  • string $extra: (optional) any AND or ORDER BY or LIMIT or anything you want to add.
set_error (line 61)

Add an error message to SESSION['errors'] array.

The $_SESSION['errors'] array stores error messages.

void set_error ([string $str = null])
  • string $str: message to add (optional)
set_msg (line 23)

Add a message to SESSION['messages'] array.

The $_SESSION['messages'] array stores general or success messages.

void set_msg ([string $str = null])
  • string $str: message to add (optional)
show_error (line 74)

Show errors messages.

Iterates through $_SESSION['errors'] and displays them in a ul.

void show_error ([string $class = 'error'])
  • string $class: css class for message style
show_msg (line 36)

Show messages.

Iterates through $_SESSION['messages'] and displays them in a ul.

void show_msg ([string $class = 'msg'])
  • string $class: css class for message style
show_tabs (line 173)

Show user tabs, based on an array.

void show_tabs (array $tabs, string $current)
  • array $tabs: array of tabs (name=>href)
  • string $current: name of tab to highlight

Documentation generated on Mon, 8 Nov 2004 13:43:06 -0800 by phpDocumentor 1.3.0RC3