I have the following array, coming from a form, with multilingual data like this:
Array
(
[en_name] => ...........
[en_description] => ...........
[gr_name] => ...........
[gr_description] => ...........
)
How can this array be converted into a two dimensional like:
Array
(
[en] => Array
(
[name] => ...........
[description] => ...........
)
[gr] => Array
(
[name] => ...........
[description] => ...........
)
)
Use this code:
$finalArr = array();
foreach($arr as $key => $val) {
$tok = explode('_', $key);
$finalArr[$tok[0]][$tok[1]] = $val;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With