logo
Home XtGem- Templates- XtScript- bottom
XtGemmanual

XtScript functions

strstr

Returns all of $haystack starting from and including the first occurrence of $needle to the end.

Syntax

[var $... = ]call strstr $haystack=…;$needle=…[;$before_needle=…][...] optional · ... your value

Notes

Returns the part of $haystack starting from and including the first occurrence of $needle to the end of $haystack
If $before_needle=1 the function returns the part of $haystack before the first occurrence of $needle (excluding $needle)

Example

<!--parser:xtscript-->
var $haystack = abcdefghijklm
var $needle = g

var $position = call strstr $haystack=$haystack; $needle=$needle; $before_needle=1 ;
print haystack = $haystack<br />
print needle = $needle<br />
print position = $position<hr />

var $position = call strstr $haystack=$haystack; $needle=$needle; $before_needle=0 ;
print haystack = $haystack<br />
print needle = $needle<br />
print position = $position
<!--/parser:xtscript-->

Copy as text

Output reload

haystack = abcdefghijklm
needle = g
position = abcdef
haystack = abcdefghijklm
needle = g
position = ghijklm

Related

stripos stristr strpos strrchr strripos strrpos substr

XtGem manual · all sections

Powered by XtGem
About us Contact Forum top