Answer the question
In order to leave comments, you need to log in
Sampling from an array by value?
Hello!
I have an array like this:
[0] => Array
(
[good] => 1
[status] => 0
)
[1] => Array
(
[good] => 2
[status] => 0
)
[2] => Array
(
[good] => 3
[status] => 0
)
[3] => Array
(
[good] => 4
[status] => 0
)
[4] => Array
(
[good] => 5
[status] => 0
)
[5] => Array
(
[good] => 6
[status] => 0
)
[6] => Array
(
[good] => 7
[status] => 0
)
[7] => Array
(
[good] => 8
[status] => 0
)
[8] => Array
(
[good] => 9
[status] => 0
)
[9] => Array
(
[good] => 10
[status] => 0
)
[10] => Array
(
[good] => 11
[status] => 0
)
Answer the question
In order to leave comments, you need to log in
Filter the array:
$selected_items = array_filter($inp_array, function($item){return $item['status'] == 0;});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question