Вверх

Блог
RSS лента

Помогите выиграть конкурс.
Займет не больше минуты!
ТЫЦ на ссылку

Ответить на комментарий

Простой способ определить последний элемент foreach

Без подсчета количества элементов, без счетчиков, просто используем функцию next().

  1. foreach ($m_arr as $val) {
  2.   echo $val;
  3.  
  4.   if (!next($m_arr)) {
  5.     echo "элементы закончились, выйти?";
  6.   }
  7. }

Ваша оценка: Пусто Средняя: 4 (2 голосов)

Ответить

 
  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Строки и параграфы переносятся автоматически.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Image links from G2 are formatted for use with Lightbox2
  • Image links with 'rel="lightshow"' in the <a> tag will appear in a Lightbox slideshow when clicked on.
  • Links to HTML content with 'rel="lightframe"' in the <a> tag will appear in a Lightbox when clicked on.
  • Links to video content with 'rel="lightvideo"' in the <a> tag will appear in a Lightbox when clicked on.
  • Links to inline or modal content with 'rel="lightmodal"' in the <a> tag will appear in a Lightbox when clicked on.

Подробнее о форматировании

Главная | Портфолио | Услуги | Контакты | Блог