Open ghost opened 6 years ago
Currently PHP has nothing for the "prefix and suffix test":
http://hyperpolyglot.org/scripting#prefix-suffix-test
However you can do this with substr_compare:
substr_compare
http://php.net/substr-compare
Examples prefix:
$ php -r 'echo substr_compare("abcde", "ab", 0, 2);' 0
$ php -r 'echo substr_compare("abcde", "ac", 0, 2);' -1
Examples suffix:
$ php -r 'echo substr_compare("abcde", "de", -2);' 0
$ php -r 'echo substr_compare("abcde", "df", -2);' -1
Currently PHP has nothing for the "prefix and suffix test":
http://hyperpolyglot.org/scripting#prefix-suffix-test
However you can do this with
substr_compare
:http://php.net/substr-compare
Examples prefix:
Examples suffix: