usort($variants, function($a, $b) {
return strcmp($a->name, $b->name);
});
$unique = [];
foreach ($arr as $n) {
$unique[$n->name] = $n;
}
$unique = array_values($unique);
на JS...
document.querySelectorAll('.scroll_list li').forEach(n => {
n.innerHTML = n.textContent.replace(/\d+ шт./, '<span>$&</span>');
});
// или
for (const n of document.querySelector('.scroll_list').children) {
n.innerHTML = n.innerText.replace(/\S+ \S+$/, m => `<span>${m}</span>`);
}
...или PHP
span
создавался сразу. $ta = mysqli_connect($link,"SELECT * FROM name_table");
$pattern = '/Сумма задания: (\d+\.\d+)/';
usort($arr, function($a, $b) use($pattern) {
preg_match($pattern, $a, $ma);
preg_match($pattern, $b, $mb);
return $mb[1] - $ma[1];
});
$grouped = [];
foreach ($arr as $n) {
$id = $n['User_ID'];
$grouped[$id] = $grouped[$id] ?? $n;
$grouped[$id]['arrGorodVievs'] += $n['arrGorodVievs'];
}
$numArr = count($array);
$numElems = count($array[0]);
$combinations = [];
$numCombinations = pow($numElems, $numArr);
for ($i = 0; $i < $numCombinations; $i++) {
$combination = [];
for ($j = 0; $j < $numArr; $j++) {
$arrIndex = $j;
$elIndex = $i / pow($numElems, $j) % $numElems;
$combination[] = $array[$arrIndex][$elIndex];
}
$combinations[] = $combination;
}
function createTree($data, $idField, $parentField, $rootParent) {
foreach ($data as $n) {
$tree[$n[$idField]] = $n;
}
foreach ($data as $n) {
$tree[$n[$parentField]]['children'][] = &$tree[$n[$idField]];
}
return $tree[$rootParent]['children'];
}
$tree = createTree($arr, 'category_id', 'parent_id', '');
echo implode('<br>', array_map(function($n, $i) use(&$result) {
return
"Книгу ".$result['BOOKS'][$i]['bookName'].
" написали для машины ".$n['name']." в ".$n['year'].
" году, можно заказать по электронной почте ".$result['BOOKS'][$i]['authorEmail'];
}, $result['CARS'], array_keys($result['BOOKS'])));
$count = array_reduce(array_keys($arr), function($acc, $n) {
return $acc + (strpos($n, 'my.key') === 0);
}, 0);
$k = array_keys($arr);
$v = array_values($arr);
sort($k);
sort($v);
$arr = array_combine($k, $v);
array_walk_recursive($arr, function(&$val, $key) {
$val = trim($val);
});
date_create(2019-05-16)