32 lines
649 B
PHP
32 lines
649 B
PHP
<?php
|
|
|
|
namespace PhpZip\Util;
|
|
|
|
/**
|
|
* String Util
|
|
*/
|
|
class StringUtil
|
|
{
|
|
|
|
/**
|
|
* @param string $haystack
|
|
* @param string $needle
|
|
* @return bool
|
|
*/
|
|
public static function startsWith($haystack, $needle)
|
|
{
|
|
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
|
|
}
|
|
|
|
/**
|
|
* @param string $haystack
|
|
* @param string $needle
|
|
* @return bool
|
|
*/
|
|
public static function endsWith($haystack, $needle)
|
|
{
|
|
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0
|
|
&& strpos($haystack, $needle, $temp) !== false);
|
|
}
|
|
}
|