random_element()

random_element($array) Parameters: $array (array) – Input array Returns: A random element from the array Return type: mixed Takes an array as input and returns a random element from it. Usage example: $quotes = array( "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", "Don't stay in bed, unless you can make money in bed. - George Burns", "We didn't lose the game; we just ran out of time. - Vince Lombardi", "If everythin

element()

element($item, $array[, $default = NULL]) Parameters: $item (string) – Item to fetch from the array $array (array) – Input array $default (bool) – What to return if the array isn’t valid Returns: NULL on failure or the array item. Return type: mixed Lets you fetch an item from an array. The function tests whether the array index is set and whether it has a value. If a value exists it is returned. If a value does not exist it returns NULL, or whatever you’ve specified as the defaul

elements()

elements($items, $array[, $default = NULL]) Parameters: $item (string) – Item to fetch from the array $array (array) – Input array $default (bool) – What to return if the array isn’t valid Returns: NULL on failure or the array item. Return type: mixed Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist it is set to NULL, or whatever you’ve specified as the default value via the third parameter. Exa

delete_files()

delete_files($path[, $del_dir = FALSE[, $htdocs = FALSE]]) Parameters: $path (string) – Directory path $del_dir (bool) – Whether to also delete directories $htdocs (bool) – Whether to skip deleting .htaccess and index page files Returns: TRUE on success, FALSE in case of an error Return type: bool Deletes ALL files contained in the supplied path. Example: delete_files('./path/to/directory/'); If the second parameter is set to TRUE, any directories contained within the supplied ro

CI_Upload::initialize()

initialize([array $config = array()[, $reset = TRUE]]) Parameters: $config (array) – Preferences $reset (bool) – Whether to reset preferences (that are not provided in $config) to their defaults Returns: CI_Upload instance (method chaining) Return type: CI_Upload

CI_Upload::do_upload()

do_upload([$field = 'userfile']) Parameters: $field (string) – Name of the form field Returns: TRUE on success, FALSE on failure Return type: bool Performs the upload based on the preferences you’ve set. Note By default the upload routine expects the file to come from a form field called userfile, and the form must be of type “multipart”. <form method="post" action="some_action" enctype="multipart/form-data" /> If you would like to set your own field name simply pass its va

CI_Upload::data()

data([$index = NULL]) Parameters: $data (string) – Element to return instead of the full array Returns: Information about the uploaded file Return type: mixed This is a helper method that returns an array containing all of the data related to the file you uploaded. Here is the array prototype: Array ( [file_name] => mypic.jpg [file_type] => image/jpeg [file_path] => /path/to/your/upload/ [full_path] => /path/to/your/upload/

set_checkbox()

set_checkbox($field[, $value = ''[, $default = FALSE]]) Parameters: $field (string) – Field name $value (string) – Value to check for $default (string) – Whether the value is also a default one Returns: ‘checked’ attribute or an empty string Return type: string Permits you to display a checkbox in the state it was submitted. The first parameter must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an ite

validation_errors()

validation_errors([$prefix = ''[, $suffix = '']]) Parameters: $prefix (string) – Error opening tag $suffix (string) – Error closing tag Returns: HTML-formatted form validation error message(s) Return type: string Similarly to the form_error() function, returns all validation error messages produced by the Form Validation Library, with optional opening and closing tags around each of the messages. Example: echo validation_errors('<span class="error">', '</span>'); /*

form_upload()

form_upload([$data = ''[, $value = ''[, $extra = '']]]) Parameters: $data (array) – Field attributes data $value (string) – Field value $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string Returns: An HTML file upload input field tag Return type: string This function is identical in all respects to the form_input() function above except that it uses the “file” input type, allowing it to be used to upload files.