From b8c283a695c8074a57d8c3dfa00934312638931d Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 19 Jul 2013 16:02:53 -0700 Subject: Dropping unecessary php: directive to function definitions in user guide --- user_guide_src/source/helpers/string_helper.rst | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'user_guide_src/source/helpers/string_helper.rst') diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index d0d302476..b6417c2a6 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -19,7 +19,7 @@ The following functions are available: random_string() =============== -.. php:function:: random_string($type = 'alnum', $len = 8) +.. function:: random_string($type = 'alnum', $len = 8) :param string $type: Randomization type :param int $len: Output string length @@ -49,7 +49,7 @@ Usage example:: increment_string() ================== -.. php:function:: increment_string($str, $separator = '_', $first = 1) +.. function:: increment_string($str, $separator = '_', $first = 1) :param string $str: Input string :param string $separator: Separator to append a duplicate number with @@ -69,7 +69,7 @@ Usage example:: alternator() ============ -.. php:function:: alternator($args) +.. function:: alternator($args) :param mixed $args: A variable number of arguments :returns: mixed @@ -98,7 +98,7 @@ your loop the next item will be returned. repeater() ========== -.. php:function:: repeater($data, $num = 1) +.. function:: repeater($data, $num = 1) :param string $data: Input :param int $num: Number of times to repeat @@ -117,7 +117,7 @@ The above would generate 30 newlines. reduce_double_slashes() ======================= -.. php:function:: reduce_double_slashes($str) +.. function:: reduce_double_slashes($str) :param string $str: Input string :returns: string @@ -133,7 +133,7 @@ Example:: strip_slashes() =============== -.. php:function:: strip_slashes($data) +.. function:: strip_slashes($data) :param array $data: Input :returns: array @@ -141,14 +141,14 @@ strip_slashes() Removes any slashes from an array of strings. Example:: - + $str = array( 'question'  => 'Is your name O\'reilly?', 'answer' => 'No, my name is O\'connor.' ); - + $str = strip_slashes($str); - + The above will return the following array:: array( @@ -163,7 +163,7 @@ The above will return the following array:: trim_slashes() ============== -.. php:function:: trim_slashes($str) +.. function:: trim_slashes($str) :param string $str: Input string :returns: string @@ -180,7 +180,7 @@ Removes any leading/trailing slashes from a string. Example:: reduce_multiples() ================== -.. php:function:: reduce_multiples($str, $character = '', $trim = FALSE) +.. function:: reduce_multiples($str, $character = '', $trim = FALSE) :param string $str: Text to search in :param string $character: Character to reduce @@ -202,7 +202,7 @@ character at the beginning and the end of the string. Example:: quotes_to_entities() ==================== -.. php:function:: quotes_to_entities($str) +.. function:: quotes_to_entities($str) :param string $str: Input string :returns: string @@ -216,7 +216,7 @@ entities. Example:: strip_quotes() ============== -.. php:function:: strip_quotes($str) +.. function:: strip_quotes($str) :param string $str: Input string :returns: string -- cgit v1.2.3-24-g4f1b From 4b184f3cbb48fcddf24f3c09d0f85baeca0f6480 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 19 Jul 2013 16:41:57 -0700 Subject: Update String helper docs --- user_guide_src/source/helpers/string_helper.rst | 204 +++++++++++------------- 1 file changed, 96 insertions(+), 108 deletions(-) (limited to 'user_guide_src/source/helpers/string_helper.rst') diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index b6417c2a6..1ca654ea6 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -5,7 +5,12 @@ String Helper The String Helper file contains functions that assist in working with strings. -.. contents:: Page Contents +.. contents:: + :local: + +.. raw:: html + +
Loading this Helper =================== @@ -14,124 +19,115 @@ This helper is loaded using the following code:: $this->load->helper('string'); +Available Functions +=================== + The following functions are available: -random_string() -=============== -.. function:: random_string($type = 'alnum', $len = 8) +.. function:: random_string([$type = 'alnum'[, $len = 8]]) :param string $type: Randomization type :param int $len: Output string length :returns: string -Generates a random string based on the type and length you specify. -Useful for creating passwords or generating random hashes. + 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: + The first parameter specifies the type of string, the second parameter + specifies the length. The following choices are available: -- **alpha**: A string with lower and uppercase letters only. -- **alnum**: Alpha-numeric string with lower and uppercase characters. -- **basic**: A random number based on ``mt_rand()``. -- **numeric**: Numeric string. -- **nozero**: Numeric string with no zeros. -- **md5**: An encrypted random number based on ``md5()`` (fixed length of 32). -- **sha1**: An encrypted random number based on ``sha1()`` (fixed length of 40). + - **alpha**: A string with lower and uppercase letters only. + - **alnum**: Alpha-numeric string with lower and uppercase characters. + - **basic**: A random number based on ``mt_rand()``. + - **numeric**: Numeric string. + - **nozero**: Numeric string with no zeros. + - **md5**: An encrypted random number based on ``md5()`` (fixed length of 32). + - **sha1**: An encrypted random number based on ``sha1()`` (fixed length of 40). -Usage example:: + Usage example:: - echo random_string('alnum', 16); + echo random_string('alnum', 16); -.. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They - are just aliases for *md5* and *sha1* respectively. + .. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They + are just aliases for *md5* and *sha1* respectively. -increment_string() -================== -.. function:: increment_string($str, $separator = '_', $first = 1) +.. function:: increment_string($str[, $separator = '_'[, $first = 1]]) :param string $str: Input string :param string $separator: Separator to append a duplicate number with :param int $first: Starting number :returns: string -Increments a string by appending a number to it or increasing the -number. Useful for creating "copies" or a file or duplicating database -content which has unique titles or slugs. + Increments a string by appending a number to it or increasing the + number. Useful for creating "copies" or a file or duplicating database + content which has unique titles or slugs. -Usage example:: + Usage example:: - echo increment_string('file', '_'); // "file_1" - echo increment_string('file', '-', 2); // "file-2" - echo increment_string('file_4'); // "file_5" + echo increment_string('file', '_'); // "file_1" + echo increment_string('file', '-', 2); // "file-2" + echo increment_string('file_4'); // "file_5" -alternator() -============ .. function:: alternator($args) :param mixed $args: A variable number of arguments :returns: mixed -Allows two or more items to be alternated between, when cycling through -a loop. Example:: + 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'); - } + 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. + 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'); - } + 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. + .. note:: To use multiple separate calls to this function simply call the + function with no arguments to re-initialize. -repeater() -========== -.. function:: repeater($data, $num = 1) +.. function:: repeater($data[, $num = 1]) :param string $data: Input :param int $num: Number of times to repeat :returns: string -Generates repeating copies of the data you submit. Example:: + Generates repeating copies of the data you submit. Example:: - $string = "\n"; - echo repeater($string, 30); + $string = "\n"; + echo repeater($string, 30); -The above would generate 30 newlines. + The above would generate 30 newlines. -.. note:: This function is DEPRECATED. Use the native ``str_repeat()`` - instead. + .. note:: This function is DEPRECATED. Use the native ``str_repeat()`` + instead. -reduce_double_slashes() -======================= .. function:: reduce_double_slashes($str) :param string $str: Input string :returns: string -Converts double slashes in a string to a single slash, except those -found in URL protocol prefixes (e.g. http://). + Converts double slashes in a string to a single slash, except those + found in URL protocol prefixes (e.g. http://). -Example:: + Example:: - $string = "http://example.com//index.php"; - echo reduce_double_slashes($string); // results in "http://example.com/index.php" + $string = "http://example.com//index.php"; + echo reduce_double_slashes($string); // results in "http://example.com/index.php" -strip_slashes() -=============== .. function:: strip_slashes($data) @@ -140,88 +136,80 @@ strip_slashes() Removes any slashes from an array of strings. -Example:: + Example:: - $str = array( - 'question'  => 'Is your name O\'reilly?', - 'answer' => 'No, my name is O\'connor.' - ); + $str = array( + 'question'  => 'Is your name O\'reilly?', + 'answer' => 'No, my name is O\'connor.' + ); - $str = strip_slashes($str); + $str = strip_slashes($str); -The above will return the following array:: + The above will return the following array:: - array( - 'question'  => "Is your name O'reilly?", - 'answer' => "No, my name is O'connor." - ); + array( + 'question'  => "Is your name O'reilly?", + 'answer' => "No, my name is O'connor." + ); -.. note:: For historical reasons, this function will also accept - and handle string inputs. This however makes it just an - alias for ``stripslashes()``. + .. note:: For historical reasons, this function will also accept + and handle string inputs. This however makes it just an + alias for ``stripslashes()``. -trim_slashes() -============== .. function:: trim_slashes($str) :param string $str: Input string :returns: string -Removes any leading/trailing slashes from a string. Example:: + Removes any leading/trailing slashes from a string. Example:: - $string = "/this/that/theother/"; - echo trim_slashes($string); // results in this/that/theother + $string = "/this/that/theother/"; + echo trim_slashes($string); // results in this/that/theother -.. note:: This function is DEPRECATED. Use the native ``trim()`` instead: - | - | trim($str, '/'); + .. note:: This function is DEPRECATED. Use the native ``trim()`` instead: + | + | trim($str, '/'); -reduce_multiples() -================== -.. function:: reduce_multiples($str, $character = '', $trim = FALSE) +.. function:: reduce_multiples($str[, $character = ''[, $trim = FALSE]]) :param string $str: Text to search in :param string $character: Character to reduce :param bool $trim: Whether to also trim the specified character :returns: string -Reduces multiple instances of a particular character occuring directly -after each other. Example:: + 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" + $string = "Fred, Bill,, Joe, Jimmy"; + $string = reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy" -If the third parameter is set to TRUE it will remove occurences of the -character at the beginning and the end of the string. Example:: + If the third parameter is set to TRUE it will remove occurrences 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" + $string = ",Fred, Bill,, Joe, Jimmy,"; + $string = reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy" -quotes_to_entities() -==================== .. function:: quotes_to_entities($str) :param string $str: Input string :returns: string -Converts single and double quotes in a string to the corresponding HTML -entities. Example:: + 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's "dinner"" + $string = "Joe's \"dinner\""; + $string = quotes_to_entities($string); //results in "Joe's "dinner"" -strip_quotes() -============== .. function:: strip_quotes($str) :param string $str: Input string :returns: string -Removes single and double quotes from a string. Example:: + 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 + $string = "Joe's \"dinner\""; + $string = strip_quotes($string); //results in "Joes dinner" \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3de130c2da3b93a3404f264e92d7b65354de3548 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 7 Feb 2014 23:31:49 +0200 Subject: [ci skip] Add return types to helper docs (+ some other formatting) --- user_guide_src/source/helpers/string_helper.rst | 39 ++++++++++++++----------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'user_guide_src/source/helpers/string_helper.rst') diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index 1ca654ea6..922bc6b8d 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -29,7 +29,8 @@ The following functions are available: :param string $type: Randomization type :param int $len: Output string length - :returns: string + :returns: A random string + :rtype: string Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes. @@ -52,13 +53,13 @@ The following functions are available: .. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They are just aliases for *md5* and *sha1* respectively. - .. function:: increment_string($str[, $separator = '_'[, $first = 1]]) :param string $str: Input string :param string $separator: Separator to append a duplicate number with :param int $first: Starting number - :returns: string + :returns: An incremented string + :rtype: string Increments a string by appending a number to it or increasing the number. Useful for creating "copies" or a file or duplicating database @@ -74,7 +75,8 @@ The following functions are available: .. function:: alternator($args) :param mixed $args: A variable number of arguments - :returns: mixed + :returns: Alternated string(s) + :rtype: mixed Allows two or more items to be alternated between, when cycling through a loop. Example:: @@ -97,12 +99,12 @@ The following functions are available: .. note:: To use multiple separate calls to this function simply call the function with no arguments to re-initialize. - .. function:: repeater($data[, $num = 1]) :param string $data: Input :param int $num: Number of times to repeat - :returns: string + :returns: Repeated string + :rtype: string Generates repeating copies of the data you submit. Example:: @@ -118,7 +120,8 @@ The following functions are available: .. function:: reduce_double_slashes($str) :param string $str: Input string - :returns: string + :returns: A string with normalized slashes + :rtype: string Converts double slashes in a string to a single slash, except those found in URL protocol prefixes (e.g. http://). @@ -131,10 +134,11 @@ The following functions are available: .. function:: strip_slashes($data) - :param array $data: Input - :returns: array + :param mixed $data: Input string or an array of strings + :returns: String(s) with stripped slashes + :rtype: mixed -Removes any slashes from an array of strings. + Removes any slashes from an array of strings. Example:: @@ -156,11 +160,11 @@ Removes any slashes from an array of strings. and handle string inputs. This however makes it just an alias for ``stripslashes()``. - .. function:: trim_slashes($str) :param string $str: Input string - :returns: string + :returns: Slash-trimmed string + :rtype: string Removes any leading/trailing slashes from a string. Example:: @@ -171,13 +175,13 @@ Removes any slashes from an array of strings. | | trim($str, '/'); - .. function:: reduce_multiples($str[, $character = ''[, $trim = FALSE]]) :param string $str: Text to search in :param string $character: Character to reduce :param bool $trim: Whether to also trim the specified character - :returns: string + :returns: Reduced string + :rtype: string Reduces multiple instances of a particular character occuring directly after each other. Example:: @@ -191,11 +195,11 @@ Removes any slashes from an array of strings. $string = ",Fred, Bill,, Joe, Jimmy,"; $string = reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy" - .. function:: quotes_to_entities($str) :param string $str: Input string - :returns: string + :returns: String with quotes converted to HTML entities + :rtype: string Converts single and double quotes in a string to the corresponding HTML entities. Example:: @@ -207,7 +211,8 @@ Removes any slashes from an array of strings. .. function:: strip_quotes($str) :param string $str: Input string - :returns: string + :returns: String with quotes stripped + :rtype: string Removes single and double quotes from a string. Example:: -- cgit v1.2.3-24-g4f1b