Skip to content

Commit 0015218

Browse files
authored
add Arrays::removeByIndex
1 parent b943d9e commit 0015218

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Arrays.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ public static function twoDimensionArrayToAssociativeArray(array $values, $key,
128128
return $return;
129129
}
130130

131+
public static function removeByIndex(array $source, $value): array
132+
{
133+
$index = array_search($source, $value, true);
134+
if ($index !== false) {
135+
unset($source[$index]);
136+
}
137+
138+
return $source;
139+
}
140+
131141
/**
132142
* @param mixed $first
133143
* @param mixed $second

0 commit comments

Comments
 (0)