From the client comes a multi-dimensional array which holds a servicename,also comes a second array which holds an ID and I am trying to use walk_array to attach the ID to the multi-dimensional array…here is the code and take a closer look where I use var_dump…
$IDs=$_POST['updateIDs'];//holds the ID
var_dump($output['form']);//holds the service
var_dump($IDs);
array_walk($output['form'], function ($value, $key) use (&$servicedta, $IDs) {
if (! isset($IDs[$key])) {
return $value;
}
$value['id'] = $IDs[$key];
$servicedta[] = $value;
});
var_dump($servicedta);return;
suppose the arrays are these:
array(1) {
[0]=>
array(1) {
["servicename"]=>
string(6) "kloper"
}
}
array(1) {
[0]=>
string(3) "443"
}
the (successful) result is this:
array(1) {
[0]=>
array(2) {
["servicename"]=>
string(6) "kloper"
["id"]=>
string(3) "443"
}
}
and not the problem…take a look at these two arrays…
array(1) {
[1]=>
array(1) {
["servicename"]=>
string(10) "τeστer"
}
}
array(1) {
[0]=>
string(3) "463"
}
here is the (unsuccessful)result of array_walk…
array(0) {
}
of course this is not cause the values are different…I am assuming that the cause of the problem is the fact that the inner array key of the first multidimensional array begins from 1…but I cannot understand how this might be a problem…and this is where I need help