Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

replaced http://us3.php.net with https://www.php.net
Source Link

One interesting way is by using array_keys() array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

Notice added Recommended answer in PHP by apokryfos
Bounty Awarded with 50 reputation awarded by chx
link to documentation
Source Link
d-_-b
  • 23.2k
  • 43
  • 174
  • 291

One interesting way is by using array_keys()array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys()array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

deleted 1 characters in body
Source Link
Ja͢ck
  • 174.2k
  • 39
  • 269
  • 317

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys withfor a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys with a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

One interesting way is by using array_keys():

foreach (array_keys($messages, 401, true) as $key) {
 unset($messages[$key]);
}

The array_keys() function takes two additional parameters to return only keys for a particular value and whether strict checking is required (i.e. using === for comparison).

This can also remove multiple array items with the same value (e.g. [1, 2, 3, 3, 4]).

Source Link
Ja͢ck
  • 174.2k
  • 39
  • 269
  • 317
Loading
lang-php

AltStyle によって変換されたページ (->オリジナル) /