$arr = array(
'title_1' => '1111111',
'title_2' => '2222222',
'title_3' => '33333333',
'title_4' => '4444444444',
'text_1' => 'aaa111',
'text_2' => 'aaa222',
'text_3' => 'aaa333',
'text_4' => 'aaaa444',
'olol' => 'wssss',
'sssss' => 'xxxxxxx',
'zzzzzzzzzzzzzz' => 'w222222sss',
'vfdsvsvds' => 'vdszxvsdsdv',
);
$group = array();
foreach($arr as $key => $item) {
if(strpos($key, 'text') !== false || strpos($key, 'title') !== false) {
$group[substr($key, -1)][$key] = $item;
}
}
$group = array_values($group);
print_r($group);
Array
(
[0] => Array
(
[title_1] => 1111111
[text_1] => aaa111
)
[1] => Array
(
[title_2] => 2222222
[text_2] => aaa222
)
[2] => Array
(
[title_3] => 33333333
[text_3] => aaa333
)
[3] => Array
(
[title_4] => 4444444444
[text_4] => aaaa444
)
)