logo
Home XtGem- Templates- XtScript- bottom
XtGemmanual

XtScript functions

strpos

Find the position of the first occurrence of a substring in a string

Syntax

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

Notes

negative $offset values do not work

Example

<!--parser:xtscript-->
var $haystack = abefcdefghijklmnopqrstuvwxyz
var $needle = op
var $offset = 0
var $position = call strpos $haystack=$haystack; $needle=$needle; $offset=$offset ;
print haystack = $haystack<br />
print needle = $needle <br />
print offset = $offset <br />
print position = $position
<!--/parser:xtscript-->

Copy as text

Output reload

haystack = abefcdefghijklmnopqrstuvwxyz
needle = op
offset = 0
position = 16

Related

stripos stristr strpos strrchr strripos strrpos strstr substr

XtGem manual · all sections

Powered by XtGem
About us Contact Forum top