logo
Home XtGem- Templates- XtScript- bottom
XtGemmanual

XtScript functions

strripos

Find the position of the last occurrence of a case-insensitive substring in a string

Syntax

[var $... = ]call strripos $haystack=…;$needle=…[;$offset=…][...] optional · ... your value

Notes

negative $offset values count from the end of $haystack
positive $offset values count from the start of $haystack

Example

<!--parser:xtscript-->
# Needle is at positions 2 and 15
var $haystack = abcdefghijklmabcdefghijklm
var $needle = CDE

var $offset = 0
var $position = call strripos $haystack=$haystack; $needle=$needle; $offset=$offset ;
print haystack = $haystack<br />
print needle = $needle<br />
print offset = $offset<br />
print position = $position<hr />

var $offset = -12
var $position = call strripos $haystack=$haystack; $needle=$needle; $offset=$offset ;
print haystack = $haystack<br />
print needle = $needle<br />
print offset = $offset<br />
print position= $position<hr />
<!--/parser:xtscript-->

Copy as text

Output reload

haystack = abcdefghijklmabcdefghijklm
needle = CDE
offset = 0
position = 15
haystack = abcdefghijklmabcdefghijklm
needle = CDE
offset = -12
position= 2

Related

stripos stristr strpos strrchr strrpos strstr substr

XtGem manual · all sections

Powered by XtGem
About us Contact Forum top