$fields = [
'email' => '1@1.ru',
'author' => 'автор',
'test' => 'тест',
'submit_button' => 'поехали !!!',
];
$myorder = [
'author',
'email',
'url',
'comment',
'cancel_reply_before',
'cancel_reply_link',
'cancel_reply_after',
'submit_button',
'submit_field'
];
$new_fields = [];
foreach($myorder as $key){
if (isset($fields[ $key ])) {
$new_fields[$key] = $fields[ $key ];
unset( $fields[$key] );
}
}
if(count($fields)) {
$new_fields = array_merge($new_fields, $fields);
}
print_r($new_fields);
Результат
Array
(
[author] => автор
[email] => 1@1.ru
[submit_button] => поехали !!!
[test] => тест
)