Skip to content

[13.x] Add concurrent to Arr#60883

Open
shaedrich wants to merge 10 commits into
laravel:13.xfrom
shaedrich:array-concurrent
Open

[13.x] Add concurrent to Arr#60883
shaedrich wants to merge 10 commits into
laravel:13.xfrom
shaedrich:array-concurrent

Conversation

@shaedrich

@shaedrich shaedrich commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Current

Looping over multiple arrays in parallel can be cumbersome or even imperformant when done poorly.

$foo = [1, 2];
$bar = [3, 4];

foreach ($foo as $fooKey => $fooValue) {
	foreach ($bar as $barKey => $barValue) {
		//
	}
}

// or

foreach ($foo as $fooKey => $fooValue) {
	$barValue = $bar[$fooKey];
	//
}

Proposed

$foo = [1, 2];
$bar = [3, 4];
$baz = Arr::concurrent($foo, $bar);

foreach ($baz as $key => [$fooValue, $barValue]) {
	//
}

This is especially helpful when having more than just two arrays.

@shaedrich

Copy link
Copy Markdown
Contributor Author

Failing tests seem to be unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant