str_contains
Available since Exponential 6.0.13.
Summary
str_contains( haystack, needle ) — PHP 8.0+; fallback for older PHP
Description
PHP string function operators for Exponential templates.
Provides template access to PHP string functions documented at https://www.php.net/manual/en/ref.strings.php that are NOT already covered by existing Exponential template operators.
The piped input value maps to the primary string argument of each PHP function. Additional template parameters map to the remaining PHP arguments in left-to-right positional order.
The following operators are intentionally NOT implemented in this class because they are already available as built-in Exponential template operators: chr, ord, trim, nl2br, rot13/str_rot13, crc32, md5, sha1, concat, indent, upcase/strtoupper, downcase/strtolower, count_chars (mb_strlen), count_words, break (nl2br), wrap/wordwrap, shorten, pad/str_pad, upfirst/ucfirst, upword/ucwords, simplify, wash/htmlspecialchars, append, prepend, merge, contains, compare, extract, extract_left, extract_right, begins_with, ends_with, implode, explode, repeat/str_repeat, reverse/strrev, insert, remove, replace, unique, array_sum.
Creative additions: - ristring: str_replace(search, replace, subject) — case-sensitive replace - rstring: str_ireplace(search, replace, subject) — case-insensitive replace
Examples
{$str|str_contains("needle")}Source
Implemented by eZTemplateStringsOperator (lib/eztemplate/classes/eztemplatestringsoperator.php).
See also
Generated example: str_contains
Added to the reference for Exponential 6.0.15: the 4.x reference had no page for this operator.
Contributors
- Graham Brookins Updated
Comments
Add a comment