Find out if $haystack ends with $needle
@param string $haystack
@param string $needle
@return boolean
336789
public static function endsWith( $haystack, $needle )
	{
		$strlen = strlen( $haystack );
		$testlen = strlen( $needle );
		if ( $testlen > $strlen ) return false;
		return substr_compare( $haystack, $needle, $strlen - $testlen, $testlen ) === 0;
	}
244934
public function arraySearch($needle, $haystack)
    {
        if (empty($needle) || empty($haystack)) {
            return false;
        }

        foreach ($haystack as $key => $value) {
            $exists = 0;
            foreach ($needle as $nkey => $nvalue) {
                if (!empty($value[$nkey]) && $value[$nkey] === $nvalue) {
                    $exists = 1;
                } else {
                    $exists = 0;
                }
            }

            if ($exists) {
                return $key;
            }
        }

        return false;
    }
887610
public static function getStartBeforeLast(string $haystack, string $needle)
    {
        $end = self::getEndAfterLast($haystack, $needle);
        $length = -1 * (strlen($end) + strlen($needle));
        return substr($haystack, 0, $length);
    }
742125
public static function stringBeginsWith($haystack, $needle)
    {
        if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
            return true;
        }

        return false;
    }
1316621
public static function endsWith($haystack, $needles)
    {
        foreach ((array) $needles as $needle) {
            if (substr($haystack, -strlen($needle)) === (string) $needle) {
                return true;
            }
        }

        return false;
    }
1045059
public static function hasAllValuesMultiDimensional(array $haystack, array $needles)
    {
        $return = true;
        foreach ($needles as $needle) {
            if (!in_array($needle, $haystack)) {
                $return = false;
                break;
            }
        }

        return $return;
    }
336391
public static function endsWith($haystack, $needle, $ignoreCase = false)
    {
        if ($ignoreCase) {
            return strripos($haystack, $needle) === strlen($haystack) - strlen($needle);
        } else {
            return substr_compare($haystack, $needle, -strlen($needle)) === 0;
        }

    }
783606
public static function getEndAfterLast(string $haystack, string $needle) : string
    {
        $lastOccurence = strrchr($haystack, $needle);
        if ($lastOccurence === false) {
            return $haystack;
        }
        return ltrim(strrchr($haystack, $needle), $needle);
    }
1332507
public static function collectionContains($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if ($value === $needle) {
                return true;
            }
        }

        return false;
    }
981782
public static function getNeedlePositions($haystack, $needle)
    {
        $start = 0;
        $result = array();
        $needleLength = strlen($needle);

        while (($pos = strpos($haystack, $needle, $start)) !== false) {
            $start = $pos + 1;

            // Calculate starting and ending positions
            $startPos = $pos;
            $endPos = $pos + $needleLength;

            // Save them
            $result[$startPos] = $endPos;
        }

        return $result;
    }
168266
public static function endsWith($needle, $haystack, $caseSensitive = true)
    {
        list($needle, $haystack) = self::transformCase($needle, $haystack, $caseSensitive);

        return (self::substring($haystack, -(self::length($needle))) === $needle);
    }
1239455
public function in_multiarray($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if (is_array($value)) {
                if ($this->in_multiarray($needle, $value)) {
                    return true;
                }
            } else {
                if ($value == $needle) {
                    return true;
                }
            }
        }
        return false;
    }
630345
public static function contains( $needle, $haystack, $strict = false )
    {
        foreach ( $haystack as $_index => $_value )
        {
            if ( is_string( $_value ) )
            {
                if ( 0 === strcasecmp( $needle, $_value ) )
                {
                    return true;
                }
            }
            else if ( in_array( $needle, $_value, $strict ) )
            {
                return true;
            }
        }

        return false;
    }
1143622
public function starts_with( $haystack, $needle ) {
		if ( '' === $haystack || '' === $needle ) {
			return false;
		}
		if ( $haystack === $needle ) {
			return true;
		}

		return strncmp( $haystack, $needle, strlen( $needle ) ) === 0;
	}
723780
protected function findall(string $haystack, $needle): array
    {
        $lastPos = 0;
        $positions = [];
        while (($lastPos = strpos($haystack, $needle, $lastPos)) !== false) {
            $positions[] = $lastPos;
            $lastPos = $lastPos + 1;
        }
        return $positions;
    }
1003507
public static function contains(string $haystack, string $needle, int $offset = 0): bool
    {
        return self::strpos($haystack, $needle, $offset) !== false;
    }
1112711
public function arrayMultiSearch($needle, $haystack) {
        foreach ($haystack as $key => $data) {
            if (in_array($needle, $data)) {
                return $key;
            }
        }
        return false;
    }