07 January 2011

PHP - Starts|ends with

Two convient general purpose functions from .NET for PHP:

function startsWith($Text, $Value){
  return strpos($Text, $Value) === 0;
}

function endsWith($Text, $Value){
  return strrpos($Text, $Value) === strlen($Text) - strlen($Value);
}

No comments:

Post a Comment