$grouped = [];
foreach ($arr as [ 'id' => $id, 'name' => $name, 'key' => $key ]) {
$grouped[$key][$name] ??= [ 'name' => $name, 'ids' => [] ];
$grouped[$key][$name]['ids'][] = $id;
}
foreach ($keys as $k) {
$$k = array_map(fn($n) => [
'name' => $n['name'],
'ids' => implode(', ', $n['ids'])
], array_values($grouped[$k] ?? []));
}
import Foundation
let numbers = [5, 1, 6, 2, 4, 3]
print(numbers.min) // 1
print(numbers.max) // 6
var minNumber: Int = 0
var maxNumber: Int = 0
for number in numbers {
if number < minNumber {
minNumber = number
}
else if maxNumber < number {
maxNumber = number
}
}
print(minNumber) // 1
print(maxNumber) // 6
var minNumber: Int = 0
var maxNumber: Int = 0
numbers.forEach { number in
if number < minNumber {
minNumber = number
}
else if maxNumber < number {
maxNumber = number
}
}
print(minNumber) // 1
print(maxNumber) // 6
add_action( 'wpcf7_before_send_mail',
function( $contact_form, &$abort, $submission ) {
// Getting user input through the your-email field
$your_email = $submission->get_posted_data( 'your-email' );
// Getting user input through the your-message field
$your_message = $submission->get_posted_data( 'your-message' );
// Do some productive things here
},
10, 3
);
$array = [
'accessories' => [ /* ... Ваш массив ... */],
];
$tmp = [];
foreach ($array['accessories'] as $item) {
if (!isset($tmp[$item['vendor_code']])) {
$tmp[$item['vendor_code']] = $item;
continue;
}
$tmp[$item['vendor_code']]['accessory_group_id'] = implode(',',
array_unique(
explode(',', $tmp[$item['vendor_code']]['accessory_group_id'] . ',' . $item['accessory_group_id'])
)
);
}
$result_array['accessories'] = array_values($tmp);
var_dump($result_array);