Returns the count of elements contained in an array:
{array_count( array( 1, 2, 3, 4 ) )}
returns the value 4.
Returns true if an array contains an element:
{array_is_empty( array( 1, 2, 3 ) )}
will evaluate to false, while:
{array_is_empty( array() )}
gives true.
Returns true if the value $v exists in the array $a:
{array_contains( array( 1, 2, 3 ), 2 )}
will evaluate to true, while:
{array_contains( array( 1, 2, 3 ), 4 )}
gives false.
See also array_index_of (), array_find (), array_index_exists ().
Returns whether an $index exists in an array:
{array_index_exists( array( 1, 2, 3 ), 1 )}
will return true, while:
{array_index_exists( array( 1, 2, 3 ), 10 )}
returns false.
See also array_index_of (), array_contains (), array_find ().
Returns the index of a specific element value ($v) in the array or boolean false, when the
element is not contained in the array:
{array_index_of( array( "a" => "b", "c" => "d" ), "b" )}
will return "a", while:
{array_index_of( array( "a" => "b", "c" => "d" ), "c" )}
will return false, since "c" is not an element contained in the array.
See also array_find (), array_contains (), array_index_exists ().
Returns the left part of an array with the specified length ($len):
{array_left( array( 1, 2, 3, 4 ), 2 )}
returns the following array:
array( 1, 2 )
See also array_right (), array_mid ().
Returns the right part of an array with the specified length ($len):
{array_right( array( 1, 2, 3, 4 ), 2 )}
returns the following array:
array( 3, 4 )
See also array_left (), array_mid ().
Returns a part from the middle of an array, that starts at a specific $index
with the specified length ($len):
{array_mid( array( 1, 2, 3, 4 ), 1, 2 )}
returns the following array:
array( 2, 3 )
See also array_left (), array_right ().
Returns an array, where the additional elements $v1, $v2, ... have been
inserted into the source array ($a) starting from $index:
{array_insert( array( 1, 2, 3 ), 1, "a", "b" )}
returns the following array:
array( 1, "a", "b", 2, 3 )
See also array_prepend (), array_append (), array_pad ().
Returns an array with the additional values $v1, $v2, ... appended to the
original array ($a):
{array_append( array( 1, 2, 3 ), 4, 5 )}
returns the following array:
array( 1, 2, 3, 4, 5 )
See also array_prepend (), array_insert (), array_pad ().
Returns an array with the additional values $v1, $v2, ... prepended to the
original array ($a):
{array_prepend( array( 1, 2, 3 ), 4, 5 )}
returns the following array:
array( 4, 5, 1, 2, 3 )
See also array_append (), array_insert (), array_pad ().
Fills an array $a with the given fill value $fill up to the length len. If
the submitted array already contains values, those will not be overwritten:
{array_pad( array( 1, 2, 3 ), 5, "a" )}
returns the following array:
array( 1, 2, 3, "a", "a" )
See also array_append (), array_insert (), array_prepend (), array_fill_range ().
Returns an array of elements $from low to $high, inclusive. If $low >
$high, the sequence will be from $high to $low. If a $step value is given,
it will be used as the increment between elements in the sequence. $step should
be given as a positive number. If not specified, step will default to 1:
{array_fill_range( 0, 10, 2 )}
returns the following array:
array( 0, 2, 4, 6, 8, 10 )
See also array_pad ().
Returns a multidimensional array, which has $len elements, which all contain
the array $a:
{array_repeat( array( 1, 2 ), 2 )}
returns an array:
array( array( 1, 2 ), array( 1, 2 ) )
Returns an array which results from the given array, where the portion starting
at $index and with the length $len has been removed:
{array_remove( array( 1, 2, 3, 4, 5 ), 1, 2 )}
returns the following array:
array( 1, 4, 5 )
See also array_remove_first (), array_remove_last ().
Returns an array with the first part with the specified length $len of the
original array ($a) removed. If $len is omitted, 1 is assumed and the first
element is removed:
{array_remove_first( array( 1, 2, 3, 4 ), 2 )}
returns the following array:
array( 3, 4 )
See also array_remove_last (), array_remove ().
Returns an array with the last part with the specified length $len of the
original array ($a) removed. If $len is omitted, 1 is assumed and the last
element is removed:
{array_remove_last( array( 1, 2, 3, 4 ), 2 )}
returns the following array:
array( 1, 2 )
See also array_remove_first (), array_remove ().
Returns an array where a specific value $v1 from the original array $a has
been replaced with the new value $vNew:
{array_find_replace( array( 1, 2, 3 ), 2, "a" )}
returns the following array:
array( 1, "a", 3 )
See also array_replace (), array_find ().
Returns an array, where a given part in the original array has been
replaced. The part to replace starts with $index and is $len elements
long. The defined portion is replaced with the given values $v1, $v2,...
{array_replace( array( 1, 2, 3, 4 ), 1, 2, "a", "b", "c" )}
returns the following array:
array( 1, "a", "b", "c", 4 )
See also array_find_replace ().
Returns an array where the 2 indices $index1 and $index2 are swapped:
{array_swap( array( 1, 2, 3, 4 ), 1, 3 )}
returns the following array:
array( 1, 4, 3, 2 )
Returns an array where the elements are in reverse order as for the original
array:
{array_reverse( array( 1, 2, 3 ) )}
returns the following array:
array( 3, 2, 1 )
Returns 2 or more arrays merged into 1 single array:
{array_merge( array( "a" => "a", "b" => "b", "c" => "c" ), array( "a" => 1, "c" => 2 ) )}
returns the following array:
array( "a" => 1, "b" => "b", "c" => 2 )
See also array_intersect (), array_diff ().
Returns an array containing all the values of $a1 that are not present in
any of the other arguments ($a2, $a3,...):
{array_diff( array( 1, 2, 3, 4 ), array( 2, 4 ), array( 5 ) )}
returns the following array:
array( 1, 3 )
See also array_intersect (), array_merge ().
Returns an array containing all the values of $a1 that are present in all
the other arguments ($a2, $a3,...):
{array_intersect( array( 1, 2, 3, 4 ), array( 2 ), array( 4 ) )}
returns the following array:
array( 2, 4 )
See also array_merge (), array_diff ().
Returns the submitted array without any duplicate values:
{array_unique( array( 1, 2, 2, 3, 2, 4, 2, 2 ) )}
returns the following array:
array( 1, 2, 3, 4 )
Returns the sum of the elements in the given array:
{array_sum( array( 5, 5, 10, 20 ) )}
returns 40.
Returns an array of extracted properties from an array of objects. The
properties named in the $pList array. Each property becomes a new value in
the resulting array:
{use $productsArray}
{var $priceArray = array_extract_by_properties( $productsArray, array( "price" ) )}
{debug_dump( $priceArray )}
The first line of the code above imports an array with product objects. A
product object has at least one property price. Meaning that:
{$productArray[0]->price}
returns the price of the first product in the array. The function
array_extract_by_properties goes through the whole array of products and
stores the price in the array. The output can be something like:
array
(
[0] => 200
[1] => 199.24
[2] => 50.20
)
Returns an array containing all the values of $a1 that are not present in
any of the other arguments ($a2, $a3,...). With this function (in contrast
to array_diff) the keys are considered, too:
{hash_diff( array( "a" => "a", "b" => "b" ), array( "a" => "a", "c" => "b" ) )}
returns the following array:
array( "b" => "b" )
See also hash_diff_key (), hash_intersect (), hash_intersect_key ().
Returns an array containing all the values of $a1 that are not present in
any of the other arguments ($a2, $a3,...). With this function (in contrast
to array_diff) the keys are used for comparison:
{hash_diff_key( array( "a" => "a", "b" => "b" ), array( "a" => "a", "c" => "b" ) )}
returns the following array:
array( "b" => "b" )
See also hash_diff (), hash_intersect (), hash_intersect_key ().
Returns an array containing all the values of $a1 that are present in all
the other arguments ($a2, $a3,...). In contrast to array_intersect this
function performs additional key checks:
{hash_intersect( array( "a" => "a", "b" => "b" ), array( "a" => "a", "b" => "c" ) )}
returns the following array:
array( "a" => "a" )
See also hash_intersect_key (), hash_diff_key (), hash_diff ().
Returns an array containing all the values of $a1 that are present in all
the other arguments ($a2, $a3,...). In contrast to array_intersect this
function checks the keys instead of the values:
{hash_intersect_key( array( "a" => "a", "b" => "b" ), array( "a" => "a", "b" => "c" ) )}
returns the following array:
array( "a" => "a", "b" => "c" )
See also hash_intersect (), hash_diff (), hash_diff_key ().
Returns the keys of the provided array as an array:
{hash_keys( array( "a" => 1, "b" => 2 ) )}
returns the following array:
array( "a", "b" )
See also hash_values ().
Returns the values of the provided array as an array:
{hash_values( array( "a" => 1, "b" => 2 ) )}
returns the following array:
array( 1, 2 )
See also hash_keys ().
Returns an array, which has the values of the original array $a as the keys,
which are assigned to the keys of the original array:
{hash_flip( array( "a" => "apple", "b" => "banana", "c" => "banana" ) )}
returns the following array:
array( "apple" => "a", "banana" => "c" )
Returns a sorted version of the array:
{array_sort( array( 1, 3, 2, 5, 4 ) )}
returns the following array:
array( 1, 2, 3, 4, 5 )
See also hash_sort (), hash_sort_keys (), array_sort_reverse ().
Returns a sorted version of the array, but in reverse order:
{array_sort_reverse( array( 1, 3, 2, 5, 4 ) )}
returns the following array:
array( 5, 4, 3, 2, 1 )
See also hash_sort (), hash_sort_keys (), array_sort ().
Returns a sorted version of the array, maintaining the key => value
association:
{hash_sort( array( "a" => "banana", "b" => "apple" ) )}
returns the following array:
array( "b" => "apple", "a" => "banana" )
See also array_sort (), hash_sort_keys (), hash_sort_reverse ().
Returns a reverse sorted version of the array, maintaining the key => value
association:
{hash_sort_reverse( array( "a" => "banana", "b" => "apple" ) )}
returns the following array:
array( "a" => "banana", "b" => "apple" )
See also hash_sort (), hash_sort_keys (), array_sort ().
Returns a sorted version of the array, sorted by the keys of the array,
maintaining the key => value association:
{hash_sort_keys( array( "a" => "banana", "b" => "apple" ) )}
returns the following array:
array( "a" => "banana", "b" => "apple" )
See also hash_sort (), array_sort (), hash_sort_keys_reverse ().
Returns a sorted version of the array, sorted by the keys of the array in
reverse order, maintaining the key => value association:
{hash_sort_keys_reverse( array( "a" => "banana", "b" => "apple" ) )}
returns the following array:
array( "b" => "apple", "a" => "banana" )
See also hash_sort_keys (), hash_sort (), array_sort ().
Replaces the part between $index and $index + $length from the string
$before with $replace:
{str_replace( "Hello world!", 6, 5, "earth" )}
Outputs:
Hello earth!
See also: str_find_replace ().
Searches for the string find in the string source. The first occurence will
be replaced with the string replace. If the last parameter count is given,
the amount of replacements is limited to this number:
{str_find_replace( "Hello world!", "world", "earth" )}
Outputs:
Hello earth!
See also: str_replace ().
Removes the part between index and index + length from the string
before:
{str_remove( "Hello world!", 6, 5 )}
Outputs:
Hello!
See also: str_chop (), str_chop_front ().
Removes the number amount of characters from the end of the string:
{str_chop( "Hello world!", 7 )}
Outputs:
Hello
See also: str_chop_front (), str_remove ().
Removes the $number amount of characters from the beginning of the string:
{str_chop_front( "Hello world!", 6 )}
Outputs:
world!
See also: str_chop (), str_remove ().
Appends the string $s2 to the string $s1:
{str_append( "Hello", " world!" )}
Outputs:
Hello world!
Note that this function is the same as using the dot operator.
See also str_prepend (), str_pad_right (), str_pad_left (), str_fill ().
Prepends the string $s2 to the string $s1:
{str_prepend( "Hello", " world!" )}
Outputs:
world!Hello
Note that this function is the same as using the dot operator with switched arguments.
See also str_append (), str_pad_left (), str_pad_right (), str_fill ().
Pads the string $str to the length $length with the string $fill.
The padding will be prepended to the string $str:
{str_pad_left( " You got the BFG", 20, "-" )}
Outputs:
---- You got the BFG
See also str_pad_right (), str_prepend (), str_append (), str_fill ().
Pads the string $str to the length $length with the string $fill.
The padding will be appended to the string $str:
{str_pad_right( "You got the BFG ", 20, "-" )}
Outputs:
You got the BFG ----
See also str_pad_left (), str_append (), str_prepend (), str_fill ().
Compares string $s1 with $s2 and returns 0 if both strings are equal. This function
returns a negative value if $s1 is smaller than $s2 and returns a positive value if
$s1 is greater than $s2:
{str_compare( "Bernard", "Bernard") // = 0 }
{str_compare( "Bernard", "Fran" ) // > 0 }
{str_compare( "Fran", "Bernard" ) // < 0 }
See also str_nat_compare ().
Compares string $s1 with $s2 with a 'natural order' algorithm. This function returns 0 if
both strings are equal. A negative value is returned if $s1 is smaller than $s2 and a positive
value is returned if $s1 is greater than $s2.
The difference between str_nat_compare_() and str_compare () is how numbers are compared:
{str_compare( "img1.png", "img10.png" ) // > 0 }
{str_nat_compare( "img1.png", "img10.png" ) // < 0 }
The first function sorts pure alphabetically. The second functions recognizes the number
and therefore says that 'img10' comes after (has a higher number) than 'img1'.
See also str_compare ().
Returns the number of words in the given string $str. If no
word separator $word_sep is given, the default word seperator
is a whitespace:
{str_word_count( "Just a random sentence" )}
Outputs:
4
See also str_char_count (), str_paragraph_count ().
Returns the number of paragraphs in the given string $str. Each
paragraph is supposed to be split a blank line:
{str_paragraph_count(
"The first paragraph
The second paragraph" )}
Outputs:
2
See also str_char_count (), str_word_count ().
Returns true if the given string $str is empty, otherwise it returns false:
{str_is_empty( "" ) // true }
Returns true if the substring $find is found in the source string $source,
otherwise this function returns false:
{str_contains( "Don't you dare use the word 'party' as a verb in this shop!", "party" )}
Returns true.
See also str_starts_with (), str_ends_with (), str_index_of (), str_last_index ().
Searches the string $search in $source and returns the begin position of the first
occurrence. If an $offset is given, the searching starts at this position. This
function returns false if the $search string couldn't be found in the $source:
{str_index_of( "Don't you dare use the word 'party' as a verb in this shop!", "party" )}
{str_index_of( "Don't you dare use the word 'party' as a verb in this shop!", "a" )}
{str_index_of( "Don't you dare use the word 'party' as a verb in this shop!", "a", 12 )}
Outputs:
29
11
30
See also str_last_index (), str_contains (), str_starts_with (), str_ends_with ().
Does a reverse search the string $search in $source and returns the begin position of the first
occurrence. If an $offset is given, the searching starts at this position. This
function returns false if the $search string couldn't be found in the $source:
{str_last_index( "Don't you dare use the word 'party' as a verb in this shop!", "party" )}
{str_last_index( "Don't you dare use the word 'party' as a verb in this shop!", "a" )}
{str_last_index( "Don't you dare use the word 'party' as a verb in this shop!", "a", 38 )}
Outputs:
29
39
36
See also str_index_of (), str_contains (), str_starts_with (), str_ends_with ().
Returns the 'left' $length characters of the string $str:
{str_left( "Bernard Black" , 7 )}
Outputs:
Bernard
See also str_right (), str_mid (), str_at ().
Returns the 'right' $length characters of the string $str:
{str_right( "Bernard Black" , 5 )}
Outputs:
Black
See also str_left (), str_mid (), str_at ().
Returns the sub-string between $index and $index + $length from the string $str:
{str_mid( "Bernard Ludwig Black", 8, 6 )}
Outputs:
Ludwig
See also str_left (), str_right (), str_at ().
Returns the character that is at position $pos in the string $str:
{str_at( "Bernard", 2 )}
Outputs:
r
See also str_left (), str_mid (), str_right ().
Returns one character string with the ASCII value $char:
{str_ord( 65 )}
Outputs:
A
Formats the number $number with the given amount of decimals $decimals, separated with the
$decimal_sep character. Thousands are separated with the $thousands_sep character:
{str_number( 30000.141234", 2, ".", "," )}
Outputs:
3,000.14
Removes whitespace characters or other characters from the beginning and end of the string.
If no $charlist is given, the following characters will be removed:
| ' ': | Ordinary whitespaces. |
| \t: | A tab. |
| \n: | A newline. |
| \r: | A carriage return. |
| \0: | A null byte. |
If a $charlist is given, then the characters in that string will be stripped instead:
{ str_trim( " ...Whoohooo.. " )}
{ str_trim( " ...Whoohooo.. ", "." )}
{ str_trim( " ...Whoohooo.. ", " ." )}
Outputs:
...Whoohooo..
...Whoohooo..
Whoohooo
See also str_trim_left (), str_trim_right (), str_simplify ().
Removes whitespace characters or other characters from the beginning of the string.
This function works the same as str_trim (), except that the characters on the right side are not trimmed:
{ str_trim_left( " ...Whoohooo.. " )}
{ str_trim_left( " ...Whoohooo.. ", "." )}
{ str_trim_left( " ...Whoohooo.. ", " ." )}
Outputs:
...Whoohooo..
...Whoohooo..
Whoohooo..
See also str_trim (), str_trim_right (), str_simplify ().
Removes whitespace characters or other characters from the end of the string.
This function works the same as str_trim (), except that the characters on the left side are not trimmed:
{ str_trim_right( " ...Whoohooo.. " )}
{ str_trim_right( " ...Whoohooo.. ", "." )}
{ str_trim_right( " ...Whoohooo.. ", " ." )}
Outputs:
...Whoohooo
...Whoohooo..
...Whoohooo
See also str_trim (), str_trim_left (), str_simplify ().
Substitutes newlines, tabs, and multiple spaces from the string $str and replaces it with a single blank.
Whitespace in the beginning and at the end of the $str are removed:
{str_simplify( " my\t \n string \n " )}
Outputs:
my string
See also str_trim (), str_trim_left (), str_trim_right ().
Splits the string $str with the $separator and returns it as an array. If a maximum max is given, the
return array will consist of maximum $max elements:
{str_split( "Bernard-Ludwig-Black", "-" )}
Will return an array with the elements:
[0] => "Bernard",
[1] => "Ludwig",
[2] => "Black".
See also str_join ().
Joins an array with strings, $array together. Between each element a separator is
inserted:
{str_join( array( "Bernard", "Ludwig", "Black" ) , "-"}
Outputs:
Bernard-Ludwig-Black
See also str_split ().
Returns a string with only upper case characters of the source string $str:
{ str_upper( "hEllO worLD" )}
Outputs:
HELLO WORLD
See also str_lower (), str_capitalize ().
Returns a string with only lower case characters of the source string $str:
{ str_lower( "hEllO worLD" )}
Outputs:
hello world
See also str_upper (), str_capitalize ().
Returns a string of which the first character is capitalized. Other characters
remain unchanged:
{str_capitalize( "hello WORLD" )}
Outputs:
Hello WORLD
See also str_lower (), str_upper ().
Returns the reversed string of $str:
{str_reverse( "Hello world" )}
Outputs:
dlrow olleH
Returns a wrapped string of the source string $str. The $width specifies after how
the $break character should be inserted. If $cut_word is given and
set to true, it will directly insert the $break in the word. Otherwise the word will be
finished and the $break will be inserted after the word:
{str_wrap("Don't you dare use the word 'party' as a verb in this shop!", 20, "<br/>\n" )}
{str_wrap("Don't you dare use the word 'party' as a verb in this shop!", 20, "\n", true )}
Outputs:
Don't you dare use the <br/>
word 'party' as a verb <br/>
in this shop!
Don't you dare use t
he word 'party' as a
verb in this shop!
Returns a MIME base64 encoded string from the $str:
{str_base64_encode( "I don't want to be encoded!" )}
Outputs:
SSBkb24ndCB3YW50IHRvIGJlIGVuY29kZWQh
See also str_base64_decode ().
Decodes the given MIME base64 $str and returns the original data:
{str_base64_decode( "SSBkb24ndCB3YW50IHRvIGJlIGVuY29kZWQh" )}
Outputs:
I don't want to be encoded!
See also str_base64_encode ().