From c112453356bb3c49c9adaecb3fda1ccd04a92be6 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Sun, 9 Dec 2007 19:26:17 +0000 Subject: documented strip_quotes(), quotes_to_entities(), reduce_multiples() --- user_guide/helpers/string_helper.html | 145 +--------------------------------- 1 file changed, 1 insertion(+), 144 deletions(-) (limited to 'user_guide/helpers/string_helper.html') diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html index 37902177e..554afc824 100644 --- a/user_guide/helpers/string_helper.html +++ b/user_guide/helpers/string_helper.html @@ -1,144 +1 @@ - - - - -CodeIgniter User Guide : String Helper - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

CodeIgniter User Guide Version 1.5.4

-
- - - - - - - - - -
- - -
- - - -
- - -

String Helper

- -

The String Helper file contains functions that assist in working with strings.

- - -

Loading this Helper

- -

This helper is loaded using the following code:

-$this->load->helper('string'); - -

The following functions are available:

- -

random_string()

- -

Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.

- -

The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:

- - - - -

Usage example:

- -echo random_string('alnum', 16); - - -

alternator()

- -

Allows two or more items to be alternated between, when cycling through a loop. Example:

- -for ($i = 0; $i < 10; $i++)
-{
-    echo alternator('string one', 'string two');
-}
-
- -

You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.

- -for ($i = 0; $i < 10; $i++)
-{
-    echo alternator('one', 'two', 'three', 'four', 'five');
-}
-
- -

Note: To use multiple separate calls to this function simply call the function with no arguments to re-initialize.

- - - -

repeater()

-

Generates repeating copies of the data you submit. Example:

-$string = "\n";
-echo repeater($string, 30);
- -

The above would generate 30 newlines.

-

reduce_double_slashes()

-

Converts double slashes in a string to a single slash, except those found in http://. Example:

-$string = "http://www.example.com//index.php";
-echo reduce_double_slashes($string); // results in "http://www.example.com/index.php"
-

trim_slashes()

-

Removes any leading/trailing slashes from a string. Example:
-
- $string = "/this/that/theother/";
-echo trim_slashes($string); // results in this/that/theother

-
- - - - - - - \ No newline at end of file + CodeIgniter User Guide : String Helper

CodeIgniter User Guide Version 1.5.4


String Helper

The String Helper file contains functions that assist in working with strings.

Loading this Helper

This helper is loaded using the following code:

$this->load->helper('string');

The following functions are available:

random_string()

Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.

The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:

Usage example:

echo random_string('alnum', 16);

alternator()

Allows two or more items to be alternated between, when cycling through a loop. Example:

for ($i = 0; $i < 10; $i++)
{
    echo alternator('string one', 'string two');
}

You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.

for ($i = 0; $i < 10; $i++)
{
    echo alternator('one', 'two', 'three', 'four', 'five');
}

Note: To use multiple separate calls to this function simply call the function with no arguments to re-initialize.

repeater()

Generates repeating copies of the data you submit. Example:

$string = "\n";
echo repeater($string, 30);

The above would generate 30 newlines.

reduce_double_slashes()

Converts double slashes in a string to a single slash, except those found in http://. Example:

$string = "http://www.example.com//index.php";
echo reduce_double_slashes($string); // results in "http://www.example.com/index.php"

trim_slashes()

Removes any leading/trailing slashes from a string. Example:

$string = "/this/that/theother/";
echo trim_slashes($string); // results in this/that/theother

reduce_multiples()

Reduces multiple instances of a particular character occuring directly after each other. Example:

$string="Fred, Bill,, Joe, Jimmy";
$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"

The function accepts the following parameters: reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string) The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced. The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example: $string=",Fred, Bill,, Joe, Jimmy,";
$string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy"

quotes_to_entities()

Converts single and double quotes in a string to the corresponding HTML entities. Example:

$string="Joe's \"dinner\"";
$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;"

strip_quotes()

Removes single and double quotes from a string. Example:

$string="Joe's \"dinner\"";
$string=strip_quotes($string); //results in "Joes dinner"
\ No newline at end of file -- cgit v1.2.3-24-g4f1b