La forma estándar de PHP para probar si una cadena $str
termina con una subcadena $test
es:¿Cuál es la prueba más eficiente de si una cadena PHP termina con otra cadena?
$endsWith = substr($str, -strlen($test)) == $test
¿Es esta la forma más rápida?
similares: http://stackoverflow.com/questions/834303/php-startswith- and-endswith-functions – trante
Puede encontrar ['s ($ str) -> endsWith ($ test)'] (https://github.com/delight-im/PHP-Str/blob/8fd0c608d5496d43adaa899642c1cce047e076dc/src/Str. php # L117) o ['s ($ str) -> endsWithIgnoreCase ($ test)'] (https://github.com/delight-im/PHP-Str/blob/8fd0c608d5496d43adaa899642c1cce047e076dc/src/Str.php#L131) útil, como se encuentra en [esta biblioteca independiente] (https://github.com/delight-im/PHP-Str). – caw