From b24b6bba1900d9f8be5c3975c8ef47076de50ee0 Mon Sep 17 00:00:00 2001 From: Mo Khosh Date: Fri, 15 Jan 2021 17:47:53 +0330 Subject: [PATCH] [8.x] Update the docs to reflect the merge of reduceWithKeys into the existing reduce method (#6743) * add reduceWithKeys to collections available methods * Update collections.md * update docs to reflect the merged reduceWithKeys into the existing reduce method * remove the link Co-authored-by: Taylor Otwell --- collections.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/collections.md b/collections.md index 7ba762f87a..38fbca7e92 100644 --- a/collections.md +++ b/collections.md @@ -164,7 +164,6 @@ For the majority of the remaining collection documentation, we'll discuss each m [put](#method-put) [random](#method-random) [reduce](#method-reduce) -[reduceWithKeys](#method-reducewithkeys) [reject](#method-reject) [replace](#method-replace) [replaceRecursive](#method-replacerecursive) @@ -1706,10 +1705,7 @@ The value for `$carry` on the first iteration is `null`; however, you may specif // 10 - -#### `reduceWithKeys()` {#collection-method} - -The `reduceWithKeys` method reduces an associative collection to a single value, passing the result of previous iterations along with each key / value pair to the given callback: +The `reduce` method also passes array keys in associative collections to the given callback: $collection = collect([ 'usd' => 1400, @@ -1725,7 +1721,7 @@ The `reduceWithKeys` method reduces an associative collection to a single value, $collection->reduceWithKeys(function ($carry, $value, $key) use ($ratio) { return $carry + ($value * $ratio[$key]); - }, 0); + }); // 4264