$t = &$arr;
foreach ($keys as $key) {
if (!isset($t[$key]) || !is_array($t[$key])) {
$t[$key] = [];
}
$t = &$t[$key];
}
$t['value'] = $val;
array_slice($data, $offset)
array_slice($data, $offset, $size_page)
.if ($page <= $size_page) {
array_diff($arrays, [ "none"]);
- этот способ Не работает
$newArrays = array_map(fn($arr) => array_diff($arr, [ 'none' ]), $arrays);
$grouped = [];
foreach ($arr as $brand => $items) {
foreach ($items as $item) {
$data = array_column(json_decode($item['data'], true)['cells'], 'data');
$model = array_shift($data);
if ($model) {
$grouped[$brand][$model][] = array_combine(
[ 'Year', 'Model', 'Bottom', 'Top' ],
$data
);
}
}
}
function getURLs($arr, $path = []) {
$urls = [];
foreach ($arr as $item) {
array_push($path, $item['slug']);
array_push($urls, '/'.implode('/', $path).'/', ...getURLs($item['children'], $path));
array_pop($path);
}
return $urls;
}
это вообще реально?
foreach ($arr as $item) {
$id = $item['id_product_attribute'];
if (!isset($result[$id])) {
$result[$id] = $item;
} else {
$result[$id]['attribute_name'] .= ', '.$item['attribute_name'];
}
}
$arr = array_slice(explode(' ', $str), 1);
.array_map(fn($n) => trim($n, '"'), $arr)
. echo implode('', array_map(function($author, $book) {
return '<p>Книга '.$book['nameBook'].', ее написал '.$author['fio'].', '.$author['email'].'</p>';
}, $arr['authors'], $arr['books']));
function plainArray($arr, $keys = []) {
$result = [];
foreach ($arr as $k => $v) {
$keys[] = $k;
$result += is_array($v)
? plainArray($v, $keys)
: [ implode('__', $keys) => $v ];
array_pop($keys);
}
return $result;
}