$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
)
)
SELECT `a`.`Message_ID`, `a`.`Price`, `mf`.`Path` FROM `Message2000` AS `a` LEFT JOIN `Multifield` AS `mf` ON (`mf`.`Message_ID` = `a`.`Message_ID` AND `mf`.`Field_ID` = 2341) ORDER BY IF((mf.ID AND a.Price > 0), 1, 0) DESC, mf.ID DESC, a.Price DESC
$openingHours = [
['day' => 'monday', 'time' => '08:00-20:00'],
['day' => 'tuesday', 'time' => '08:00-20:00'],
['day' => 'wednesday', 'time' => '08:00-20:00'],
['day' => 'thursday', 'time' => '10:00-20:00'],
['day' => 'friday', 'time' => '10:00-18:00'],
['day' => 'saturday', 'time' => '10:00-16:00'],
['day' => 'sunday', 'time' => '10:00-16:00'],
];
$temp = array();
$result = array();
foreach($openingHours as $key => $item) {
$temp[$item['time']][] = $item['day'];
}
foreach($temp as $key => $item){
$count = count($item) -1;
$count >= 1 ? $result[$item[0].'-'.$item[$count]] = $key : $result[$item[0]] = $key;
}
print_r($result);
Array
(
[monday-wednesday] => 08:00-20:00
[thursday] => 10:00-20:00
[friday] => 10:00-18:00
[saturday-sunday] => 10:00-16:00
)