Logo

Programming-Idioms

History of Idiom 97 > diff from v15 to v16

Edit summary for version 16 by :
New PHP implementation by user [agilla1]

Version 15

2016-02-18, 16:58:02

Version 16

2016-02-23, 13:28:03

Idiom #97 Check string suffix

Set boolean b to true if string s ends with suffix suffix, false otherwise.

Idiom #97 Check string suffix

Set boolean b to true if string s ends with suffix suffix, false otherwise.

Code
$b = (bool)preg_match(“/{$suffix}$/“, $s);
Comments bubble
Uses regular expression to check end of s for suffix
Doc URL
http://php.net/manual/en/function.preg-match.php