J
J
javanub2015-10-16 11:22:49
PHP
javanub, 2015-10-16 11:22:49

How to fill in li-shki?

For example, there is such a condition ul li li li ul . How to make each iteration of the loop insert a value into the excess like this:
1st insert ul value li li ul
2nd insert ul value value li ul
3rd insert ul value value value ul
This is all the first row. As soon as all the excesses are filled, start a new row with ul li. It may not look clear on the example, but I want to make the catalog filled in order, 4 cells in a row with display:inline-table. The result of filling should look something like this:
ul value value value value \ul
ul value value value value \ul
ul value value li li \ul if the array is over.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-10-16
@javanub

echo '[ul]';
foreach (range(0, 9) as $i)
{
  if ($i > 0 && $i % 4 == 0)
  {
    echo '[/ul]';
    echo '[ul]';
  }

  echo '[li]', 'Значение', '[/li]';
}
echo '[/ul]';

sandbox.onlinephpfunctions.com/code/625fe2576ac20a...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question