PHP: startsWith endsWith functions

 
function startsWith($needle, $haystack){  
    return preg_match('/^'.preg_quote($needle)."/", $haystack);  
}  

function endsWith($needle, $haystack){  
    return preg_match("/".preg_quote($needle) .'$/', $haystack);  
}  

No comments:

Post a Comment

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...