S
S
Stanislav Shabalin2020-04-23 00:25:06
PHP
Stanislav Shabalin, 2020-04-23 00:25:06

How to remove some elements from an array?

Good evening. I struggle with what seems to be a trivial thing, but it turns out to be a vegetable garden.
I want to slice the array by writing to the new one, but still extract them from the main one.
There is an array arr1 of 20 entries. We need to get the first 15 and put them in a new array arr2.
arr1 should be left with arr1 = arr1 - arr2.

Well, or in the foreach loop, print the first 15 from arr1 and jump out of the loop with the remainder of 5 elements in it.

I can't find an easy solution. Help, plz.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-04-23
@Starck43

array_splice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question