Supported Versions: PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8
Searches the array for a given value and returns the first corresponding key if successful
array_search(mixed $needle, array $haystack, bool $strict = false): int|string|false
public function search($value, $strict = false)
{
if (! $this->useAsCallable($value)) {
return array_search($value, $this->items, $strict);
}
foreach ($this->items as $key => $item) {
{
if (! $this->useAsCallable($value)) {
return array_search($value, $this->items, $strict);
}
foreach ($this->items as $key => $item) {
$index = key($matches);
} else {
$index = array_search($this->components->choice('Which command would you like to run?', $commandNames), $commandNames);
}
$event = $commands[$index];
} else {
$index = array_search($this->components->choice('Which command would you like to run?', $commandNames), $commandNames);
}
$event = $commands[$index];
$morphMap = Relation::morphMap();
if (! empty($morphMap) && in_array(static::class, $morphMap)) {
return array_search(static::class, $morphMap, true);
}
if (static::class === Pivot::class) {
if (! empty($morphMap) && in_array(static::class, $morphMap)) {
return array_search(static::class, $morphMap, true);
}
if (static::class === Pivot::class) {
$morphMap = Relation::morphMap();
if (! empty($morphMap) && in_array($model, $morphMap)) {
$model = array_search($model, $morphMap, true);
}
return $this->where($relation->getMorphType(), $model, null, $boolean);
if (! empty($morphMap) && in_array($model, $morphMap)) {
$model = array_search($model, $morphMap, true);
}
return $this->where($relation->getMorphType(), $model, null, $boolean);
$morphMap = Relation::morphMap();
if (! empty($morphMap) && in_array($model, $morphMap)) {
$model = array_search($model, $morphMap, true);
}
return $this->whereNot($relation->getMorphType(), '<=>', $model, $boolean);
if (! empty($morphMap) && in_array($model, $morphMap)) {
$model = array_search($model, $morphMap, true);
}
return $this->whereNot($relation->getMorphType(), '<=>', $model, $boolean);
protected function sortBindingsForSubqueryOrderBy($query)
{
return Arr::sort($query->bindings, function ($bindings, $key) {
return array_search($key, ['select', 'order', 'from', 'join', 'where', 'groupBy', 'having', 'union', 'unionOrder']);
});
}
{
return Arr::sort($query->bindings, function ($bindings, $key) {
return array_search($key, ['select', 'order', 'from', 'join', 'where', 'groupBy', 'having', 'union', 'unionOrder']);
});
}
$this->gatherApplicationInformation();
collect(static::$data)->sortBy(function ($data, $key) {
$index = array_search($key, ['Environment', 'Cache', 'Drivers']);
if ($index === false) {
return 99;
collect(static::$data)->sortBy(function ($data, $key) {
$index = array_search($key, ['Environment', 'Cache', 'Drivers']);
if ($index === false) {
return 99;
public function prependMiddleware($middleware)
{
if (array_search($middleware, $this->middleware) === false) {
array_unshift($this->middleware, $middleware);
}
{
if (array_search($middleware, $this->middleware) === false) {
array_unshift($this->middleware, $middleware);
}
public function pushMiddleware($middleware)
{
if (array_search($middleware, $this->middleware) === false) {
$this->middleware[] = $middleware;
}
{
if (array_search($middleware, $this->middleware) === false) {
$this->middleware[] = $middleware;
}
throw new InvalidArgumentException("The [{$group}] middleware group has not been defined.");
}
if (array_search($middleware, $this->middlewareGroups[$group]) === false) {
array_unshift($this->middlewareGroups[$group], $middleware);
}
}
if (array_search($middleware, $this->middlewareGroups[$group]) === false) {
array_unshift($this->middlewareGroups[$group], $middleware);
}
throw new InvalidArgumentException("The [{$group}] middleware group has not been defined.");
}
if (array_search($middleware, $this->middlewareGroups[$group]) === false) {
$this->middlewareGroups[$group][] = $middleware;
}
}
if (array_search($middleware, $this->middlewareGroups[$group]) === false) {
$this->middlewareGroups[$group][] = $middleware;
}
public function parentOfParameter($parameter)
{
$key = array_search($parameter, array_keys($this->parameters));
if ($key === 0) {
return;
{
$key = array_search($parameter, array_keys($this->parameters));
if ($key === 0) {
return;
protected function priorityMapIndex($priorityMap, $middleware)
{
foreach ($this->middlewareNames($middleware) as $name) {
$priorityIndex = array_search($name, $priorityMap);
if ($priorityIndex !== false) {
return $priorityIndex;
{
foreach ($this->middlewareNames($middleware) as $name) {
$priorityIndex = array_search($name, $priorityMap);
if ($priorityIndex !== false) {
return $priorityIndex;
$this->test->fail('Output does not contain "'.Arr::first($this->test->expectedOutputSubstrings).'".');
}
if ($output = array_search(true, $this->test->unexpectedOutput)) {
$this->test->fail('Output "'.$output.'" was printed.');
}
}
if ($output = array_search(true, $this->test->unexpectedOutput)) {
$this->test->fail('Output "'.$output.'" was printed.');
}
$this->test->fail('Output "'.$output.'" was printed.');
}
if ($output = array_search(true, $this->test->unexpectedOutputSubstrings)) {
$this->test->fail('Output "'.$output.'" was printed.');
}
}
}
if ($output = array_search(true, $this->test->unexpectedOutputSubstrings)) {
$this->test->fail('Output "'.$output.'" was printed.');
}
}