Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Find the position of the first occurrence of a substring in a string
<?php strpos(string $haystack, string $needle, int $offset = 0): int|false
<?php return $glob === $path;
}
if (0 !== strpos($path, self::getStaticPrefix($glob, $flags))) {
return false;
}
<?php $staticPrefix = self::getStaticPrefix($glob, $flags);
$regExp = self::toRegEx($glob, $flags);
$filter = function ($path) use ($staticPrefix, $regExp) {
return 0 === strpos($path, $staticPrefix) && preg_match($regExp, $path);
};
if (PHP_VERSION_ID >= 50600) {
<?php }
if ($pos - 3 === strpos($glob, '://')) {
return substr($staticPrefix, 0, $pos + 1);
}
<?php public static function toRegEx($glob, $flags = 0, $delimiter = '~')
{
if (!Path::isAbsolute($glob) && false === strpos($glob, '://')) {
throw new InvalidArgumentException(sprintf(
'The glob "%s" is not absolute and not a URI.',
$glob
<?php public static function getStaticPrefix($glob, $flags = 0)
{
if (!Path::isAbsolute($glob) && false === strpos($glob, '://')) {
throw new InvalidArgumentException(sprintf(
'The glob "%s" is not absolute and not a URI.',
$glob
<?php public static function isDynamic($glob)
{
return false !== strpos($glob, '*') || false !== strpos($glob, '{') || false !== strpos($glob, '?') || false !== strpos($glob, '[');
}
private function __construct()
<?php if (
false === strpos($glob, '/**/') &&
false === strpos($glob, '://') &&
<?php false === strpos($glob, '/**/') &&
false === strpos($glob, '://') &&
('\\' !== DIRECTORY_SEPARATOR || false === strpos($glob, '[^'))
) {
<?php false === strpos($glob, '://') &&
('\\' !== DIRECTORY_SEPARATOR || false === strpos($glob, '[^'))
) {
$results = glob($glob, defined('GLOB_BRACE') ? GLOB_BRACE : 0);
<?php {
$path = ($this->mode & self::FILTER_VALUE) ? $this->current() : parent::key();
if (0 !== strpos($path, $this->staticPrefix)) {
return false;
}