J
J
JTester2021-08-13 17:12:19
PHP
JTester, 2021-08-13 17:12:19

Why is the element not being removed from the array?

Hello! I want to remove an element from the array, but for some reason it is not removed.

My array:

$arr = [
'test' => ['users' => ['123']],
'test2' => ['users' => []]
];

I delete like this:
unset($arr['test']['users'][array_search('123', $arr['test']['users'])]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Interesting, 2021-08-14
@Swimergg

1. Try to write this in general:

$array = array('1st element', '2nd element', '3rd element');
unset($array[0]);

2. Try array_splice() again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question