Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
$data = [];
foreach($array as $item) {
if ($item['category_id'] == $item['parent_id']) $data[] = $item;
}
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', '');
function RusEnding($n, $n1, $n2, $n5) {
if($n >= 11 and $n <= 19) return $n5;
$n = $n % 10;
if($n == 1) return $n1;
if($n >= 2 and $n <= 4) return $n2;
return $n5;
}
echo RusEnding(40, "комментарий", "комментария", "комментариев");
This is called pluralization.
You can search implementations for the keyword "plural" on packagist.
Examples:
doctrine/inflector
symfony/inflector
mmucklo/inflect
wapmorgan/morphos (specially for Russian and English).
Like this
Use like this:
html_spellcount(54, 'модель|модели|моделей');
// или так
html_spellcount(54, 'модель', 'модели', 'моделей');
// выведет: 54 модели
www.yiiframework.com/doc-2.0/guide-tutorial-i18n.h...
php.net/manual/en/intro.intl.php
Here is the answer to your question - https://www.pandoge.com/moduli_i_skripty/prostoe-s...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question