Core Function Between
From Sputnik Wiki
Between( <haystack>, <firstneedle>, <secondneedle>, <case> )
Contents |
Description
Return the text between a start and end substring.
Parameters
haystack
The search to search for the substrings
firstneedle
The first substring to find
secondneedle
The second substring to find
Return Value
Success: Returns the between between the first and second substrings.
Failure: Returns empty string.
Remarks
None
Example
// String search $str = "The quick brown fox jumps over the lazy dog"; $val = Between($str, "brown", "over"); echo "'$val'\n"; // Prints fox jumps // Character search $str = "The"; $val = Between($str, "T", "e"); echo "'$val'\n"; // Prints h // Case insensitive $str = "The"; $val = Between($str, "t", "e", true); echo "'$val'\n"; // Prints h