PHP ver gevorderde |
|
Hmm ondertussen heb ik dit geschreven:
function switchKey($data, $model, $key) {
foreach($data[$model] as $k => $v) {
$data[$model][$v[$key]] = $data[$model][$k];
unset($data[$model][$k]);
}
return $data;
}
$char = switchKey($char, 'Character', 'id');
function switchKey($data, $model, $key) { foreach($data[$model] as $k => $v) { $data[$model][$v[$key]] = $data[$model][$k]; unset($data[$model][$k]); } return $data; } $char = switchKey($char, 'Character', 'id');
Werkt perfect, krijg nu terug wat ik wil.
Iemand enig idee of ik dit beter/sneller kan? |