Dieser Artikel ist auf German nicht verfügbar. Sehen Sie ihn sich auf English an
group_adjacent
TABLE OF CONTENTS
Group adjacent elements that share a property value
Definition
array group_adjacent(array $entry, &groupExpression)
Groups adjacent elements of an input array based on matching values assigned to the &groupExpression key.
Parameters
array $entry
Array to split into groups.
string &groupExpression
Key name to group by.
Returns
array
Array $entry grouped into subarrays, where each subarray is made up of all contiguous elements sharing the same value of $groupExpression.
Examples
Sample data
{
"array": [
{"key": "a"},
{"key": "b"},
{"key": "b"},
{"key": "a"}
]
}Transformation
{
group: group_adjacent(array, &key)
}Json
{
"group": [
[{"key": "a"}],
[{"key": "b"}, {"key": "b"}],
[{"key": "a"}]
]
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article