M
M
MdaUZH2016-01-21 21:00:11
PHP
MdaUZH, 2016-01-21 21:00:11

A function similar to array_shift, only by key (remove array element) - NON-BRED?

Hello.
I must say right away that the issue is easily solved as follows:

$arr = array('one' => 1, 'two' => 2);
$two = $arr['two'];
unset($arr['two'];

BUT how to do it right?
something like array_shift but by index?
What for? I just thought how to do it more correctly, + you need to get everything unnecessary from the array, and pass it on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2016-01-22
@MdaUZH

you can get everything you don't need with the array_filter filter
php.net/manual/en/function.array-filter.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question