S
S
synapse_people2018-05-23 12:46:35
PHP
synapse_people, 2018-05-23 12:46:35

How to group arrays?

There is such an array that shows empty regions in a file (where no data is written):

[
[100,150],
[0,10],
[11,20],
...
[500,750]
]

That is, an array with arrays... so it will be clearer: list($begin,$end)=$arr[0];..
How can you group its elements so that if there are 2 empty spaces that go in a row, they occupy 1 element, and not 2 different ones?
That is, from the array in the example, you need to get the following output:
[
[100,150],
[0,20],
...
[500,750]
]

?
Clarification - it is necessary that any number of consecutive regions be combined into 1 region. But if at least 1 byte is occupied between them, then they should not connect

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question