@substr - Extract a Substring
The @substr
directive in Ahmed PHP Template Engine is used to extract a portion of a string based on a starting position and optional length.
Syntax
variable
: The string to extract from.start
: The position to begin extraction (0-based index).length
(optional): The number of characters to extract.
Description
If
length
is omitted, it extracts everything fromstart
to the end of the string.Supports negative indices: a negative
start
extracts from the end of the string.
Example
Expected Output
Notes
Useful for manipulating strings dynamically within templates.
Negative
start
counts from the end of the string.If
length
is longer than the remaining string, it extracts until the end.
Last updated