<?php $data = [ ['type' => 'foo'], ]; function hasDependencyTypeLoop(array $dependencies, string $type): bool { foreach ($dependencies as ['type' => $currentType]) { if ($currentType === $type) { return true; } } return false; } function hasDependencyTypeArrayAny(array $dependencies, string $type): bool { return array_any($dependencies, fn() => $currentType === $type); } var_dump(hasDependencyTypeLoop($data, 'foo')); var_dump(hasDependencyTypeArrayAny($data, 'foo'));
You have javascript disabled. You will not be able to edit any code.