Skip to the content
Documentation

Strings

No ratings yet
Operator Summary
append Returns the input string with a custom sequence appended to it.
autolink Returns the input string with the addresses replaced by link tags.
begins_with Checks if a string starts with a specific character/sequence.
break Returns the input string with all newlines converted to HTML breaks.
chr Generates a string based on the input array of ASCII/UNICODE values.
compare Compares the contents of two strings.
concat Merges several strings into one string.
contains Checks if a string contains a specific element.
count_chars Returns the length of the input string.
count_words Returns the number of words that make up the input string.
crc32 Returns the CRC32 polynomial of the input string.
downcase Returns a lowercased version of the input string.
ends_with Checks if a string ends with a specific character/sequence.
explode Splits the input string and returns it as an array of strings.
extract Returns a portion of the input string.
extract_left Returns a portion of the start of the input string.
extract_right Returns a portion of the end of the input string.
indent Returns an indented version of the input string.
insert Returns the input string with additional text inserted at a specified position.
md5 Returns the MD5 hash of the input string.
nl2br Returns the input string with all newlines converted to HTML breaks.
ord Returns an array containing the ASCII/UNICODE values of the input string.
pad Returns a lengthened version of the input string.
prepend Returns the input string prepended with a custom sequence.
remove Returns a pruned version of the input string.
repeat Returns a repeated version of the input string.
replace Replaces elements in a string.
reverse Returns a reversed version of the input string.
rot13 Returns a ROT13 transformation of the input string.
shorten Returns a shortened version of the input string.
simpletags Returns a partially marked up version of the input string.
simplify Returns a simplified version of the input string.
trim Returns a stripped version of the input string.
upcase Returns a capitalized version of the input string.
upfirst Returns the input string with a capitalized initial letter.
upword Returns the input string with capitalized initial letters.
wash Returns an HTML-safe version of the input string.
wordtoimage Returns the input string with embedded image tags.
wrap Returns a wrapped version of the input string.

Added for Exponential 6.0.15

Name Summary
addcslashes addcslashes( string, charlist ) — charlist required
addslashes PHP string function operators for Exponential templates.
bin2hex PHP string function operators for Exponential templates.
chunk_split chunk_split( string [, chunklen [, end]] )
convert_uudecode Suppress E_WARNING for malformed uuencoded input.
convert_uuencode PHP string function operators for Exponential templates.
getenv PHP getenv()
hebrev hebrev( hebrew_text [, max_chars_per_line] )
hex2bin Returns false on invalid input; suppress PHP's E_WARNING for odd-length or non-hex strings so the template doesn't crash.
html_entity_decode html_entity_decode( string [, flags [, encoding]] ) Defaults: ENT_QUOTES | ENT_HTML5, 'UTF-8'
htmlentities htmlentities( string [, flags [, encoding [, double_encode]]] ) Defaults: ENT_QUOTES, 'UTF-8'
htmlspecialchars_decode htmlspecialchars_decode( string [, flags] ) Default: ENT_QUOTES
lcfirst PHP string function operators for Exponential templates.
levenshtein levenshtein( str1, str2 ) — str2 required
ltrim ltrim( string [, chars] )
metaphone metaphone( string [, max_phonemes] )
number_format number_format( number [, decimals [, dec_point, thousands_sep]] ) Note: PHP requires dec_point and thousands_sep to be given together.
quoted_printable_decode PHP string function operators for Exponential templates.
quoted_printable_encode PHP string function operators for Exponential templates.
quotemeta PHP string function operators for Exponential templates.
rawurldecode PHP rawurldecode()
rawurlencode PHP rawurlencode()
ristring str_replace( search, replace, subject ) — case-sensitive in-string replace Template: {$subject|ristring( "search", "replacement" )} Supports scalar and array search/replace patterns.
rstring str_ireplace( search, replace, subject ) — case-insensitive in-string replace Template: {$subject|rstring( "Search", "replacement" )} Supports scalar and array search/replace patterns.
rtrim rtrim( string [, chars] )
serialize PHP serialize()
similar_text similar_text( str1, str2 ) — returns count of matching chars; str2 required
soundex PHP string function operators for Exponential templates.
sprintf sprintf( format, ...args ) — format is operatorValue, args are template params Uses vsprintf internally to accept a flat list of positional parameters.
str_contains str_contains( haystack, needle ) — PHP 8.0+; fallback for older PHP
str_ends_with str_ends_with( haystack, needle ) — PHP 8.0+; fallback for older PHP
str_getcsv str_getcsv( string [, separator [, enclosure [, escape]]] ) PHP 8.4+ deprecates non-empty $escape; pass '' to opt-in to the RFC 4180-compliant behaviour and silence the deprecation notice.
str_shuffle PHP string function operators for Exponential templates.
str_split str_split( string [, length] )
str_starts_with str_starts_with( haystack, needle ) — PHP 8.0+; fallback for older PHP
str_word_count str_word_count( string [, format [, charlist]] ) format 0 (default) = integer count; 1 = array of words; 2 = assoc array pos=>word
strcasecmp strcasecmp( str1, str2 ) — case-insensitive comparison; str2 required
strcmp strcmp( str1, str2 ) — binary-safe comparison; str2 required
strcoll strcoll( str1, str2 ) — locale-based comparison; str2 required
strcspn strcspn( str, mask [, offset [, length]] ) — mask required
strip_tags strip_tags( string [, allowed_tags] )
stripcslashes PHP string function operators for Exponential templates.
stripos stripos( haystack, needle [, offset] ) — case-insensitive strpos; needle required
stripslashes PHP string function operators for Exponential templates.
stristr stristr( haystack, needle [, before_needle] ) — case-insensitive strstr; needle required
strlen Returns byte length. For character length use count_chars (uses mb_strlen).
strnatcasecmp strnatcasecmp( str1, str2 ) — case-insensitive natural-order comparison; str2 required
strnatcmp strnatcmp( str1, str2 ) — natural-order comparison; str2 required
strncasecmp strncasecmp( str1, str2, n ) — compare first n chars, case-insensitive; str2 and n required
strncmp strncmp( str1, str2, n ) — compare first n chars; str2 and n required
strpbrk strpbrk( haystack, char_list ) — search for any char in char_list; char_list required
strpos strpos( haystack, needle [, offset] ) — needle required
strrchr strrchr( haystack, needle ) — last occurrence; needle required
strripos strripos( haystack, needle [, offset] ) — case-insensitive strrpos; needle required
strrpos strrpos( haystack, needle [, offset] ) — needle required
strspn strspn( str, mask [, offset [, length]] ) — mask required
strstr strstr( haystack, needle [, before_needle] ) — needle required
strtok strtok( string, token ) — token required Note: PHP strtok is stateful. In a template this returns the first token only. Subsequent {strtok(token)} calls without a string will continue tokenizing.
strtr strtr( string, from, to ) or strtr( string, replace_pairs_array )
substr substr( string, start [, length] ) — start required
substr_compare substr_compare( main_str, str, offset [, length [, case_insensitive]] ) str and offset required
substr_count substr_count( haystack, needle [, offset [, length]] ) — needle required
substr_replace substr_replace( string, replace, start [, length] ) — replace and start required
unserialize PHP unserialize()
urldecode PHP urldecode()
urlencode PHP urlencode()
vsprintf vsprintf( format, args_array ) — format is operatorValue, args_array is params[0]

In this section

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.