Answer the question
In order to leave comments, you need to log in
How to reset multidimensional array values in php?
There is an array like this:
Array(
[stock] => Array(
[0] => 17-58-черный
[1] => 17-54-черный
[2] => 17-58-черный
)
[sold] => Array(
[0] => 17-58-черный
[1] => 17-54-черный
)
)
array_count_values
and replace its values with the resulting ones, so that something like this comes out:Array(
[stock] => Array(
[0] => Array
( 17-58-черный => 2 )
[1] => Array
( 17-54-черный => 1 )
)
[sold] => Array(
[0] => Array
( 17-58-черный => 1 )
[1] => Array
( 17-54-черный => 1 )
)
)
Answer the question
In order to leave comments, you need to log in
uh, isn't it?
$arr = [
'stock' => [
0 => '17-58-черный',
1 => '17-54-черный',
2 => '17-58-черный',
],
'sold' => [
0 => '17-58-черный',
1 => '17-54-черный',
]
];
$arr = array_map('array_count_values', $arr);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question