<form action="2.php" method="post"> <label for="myText"><textarea rows="5" cols="45" name="myText"></textarea></label> <input type="submit" value="Отправить"> </form> <?php /*2. Создать форму с элементом textarea. При отправке формы скрипт должен выдавать ТОП3 длинных слов в тексте. Реализовать с помощью функции.*/ function sorting($z) { function mySort($a, $b) { if (mb_strlen($a) < mb_strlen($b)) { return 1; } elseif (mb_strlen($a) > mb_strlen($b)) { return -1; } else { return 0; } } $words = explode(" ", $z); usort($words, 'mySort'); echo "ТОП 3 длинных слова:<br>"; for ($i = 0; $i < 3; $i++) { if (isset($words[$i])) { echo $words[$i] . "<br>"; } } } if (isset($_POST['myText'])) { sorting($_POST['myText']); }
$arLetter['LETTER'] = iconv('CP1251', 'UTF-8', $letter); $arLetter['VALUE'] = iconv('CP1251', 'UTF-8', $letter); if ($_GET['SORT_LETTER'] == iconv('CP1251', 'UTF-8', $letter)) { $arLetter['ACTIVE'] = 'active'; } $abc['RUS'][] = $arLetter; } //$abc['RUS']=$arLetterRus; /*$arLetterNum=array(); $arLetterNum['LETTER'] = iconv('CP1251', 'UTF-8', '123'); $arLetterNum['VALUE'] = 'NUM'; if ($_GET['SORT_LETTER']=='NUM') $arLetterNum['ACTIVE'] = 'active'; $abc['NUM']=$arLetterNum;*/ $arResult['LETTERS'] = $abc; $arNew = sorting($arResult['ITEMS'], true, false); if (is_array($arNew) && !empty($arNew)) { if ($_GET['SORT_LETTER'] != '') { foreach ($arNew as $key => $arLetterItems) { if ($_GET['SORT_LETTER'] != $key) { unset($arNew[$key]); } } } foreach ($arResult['LETTERS'] as $langKey => $arLang) { foreach ($arLang as $keyLetter => $arLetter) { if (empty($arNew[$arLetter['VALUE']])) { $arResult['LETTERS'][$langKey][$keyLetter]['EMPTY'] = 'Y'; } } }
function sorting($arr, $abc, $parent, $parent_adress = null) { $i = 0; foreach ($arr as &$val) { if ($parent === $val->parent) { $val->adress = $parent_adress . $abc[$i]; $i++; sorting($arr, $abc, $val->id_category, $val->adress); } } }
<th style="white-space: nowrap;">ME Number</th> <th style="white-space: nowrap;">Company</th> <th style="white-space: nowrap;">Facility</th> <th style="white-space: nowrap;"><a style="text-decoration: underline" href="<?php echo site_url('admin/files/new_index/?order_by=consultant&sorting=' . sorting('consultant', $order_by, $sorting) . $get); ?> ">Consultant</a></th> <th style="white-space: nowrap;"><a style="text-decoration: underline" href="<?php echo site_url('admin/files/new_index/?order_by=certification&sorting=' . sorting('certification', $order_by, $sorting) . $get); ?> ">Certificate</a></th> <th style="white-space: nowrap;"><a style="text-decoration: underline" href="<?php echo site_url('admin/files/new_index/?order_by=status&sorting=' . sorting('status', $order_by, $sorting) . $get); ?> ">Status</a></th> </tr> </thead> <tbody class="middle-align"> <?php if (!($i = $this->uri->segment(4))) { $i = 0; } foreach ($items as $item) { ?> <tr> <td><?php