Parse error: syntax error, unexpected 'echo' (T_ECHO) in foreach
-
I need to make 5 after I've been created.
li
created the followingul
And now,ul
continued to be establishedli
♪ Onlyul
must be all at the same level. Here's the code, CMS OpenCart.<?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?> <div class="children clearfix"> <ul class="children-list children-list-col clearfix"> <?php $k=0; foreach ($children as $child) {(($k%5==0) ? "</ul><ul>" :"");?> <li> <a class="link" href="<?php echo $child['href']; ?>" > <img class="thumb" src="<?php echo $child['thumb']?>" width="40" height="40" alt="" /> <span class="text"><?php echo $child['name']; ?></span></a> </li> <?php } ?> </ul> </div> <?php } ?>
There may be another solution, thank you in advance.
UPD: With that code, it makes a mistake that's in the headline.
<?php foreach ($children as $child) {(($k%5==0) ? echo "</ul><ul>" : echo"");?>
UPD: On some grounds, code
<?php $k=0; foreach ($children as $child) { if($k%5==0) { echo "</ul><ul>"; } $k++;?>
which shows signs of efficiency, thank you. tCodeIt doesn't work exactly as I need to... It's been two days since I've been tortured, and it's not about knowledge. ♪<div class="children clearfix"> <ul class="children-list children-list-col clearfix"> </ul><ul> <li> <a class="link" href="http://rumishop2/component/cmp23" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Components</span></a> </li>
<li> <a class="link" href="http://rumishop2/component/PC123" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">PC</span></a> </li> <li> <a class="link" href="http://rumishop2/component/mouse" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Mice and Trackballs</span></a> </li> <li> <a class="link" href="http://rumishop2/component/monitor" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Monitors</span></a> </li> <li> <a class="link" href="http://rumishop2/component/printer" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Printers</span></a> </li> </ul><ul> <li> <a class="link" href="http://rumishop2/component/scanner" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Scanners</span></a> </li> <li> <a class="link" href="http://rumishop2/component/web-camera" > <img class="thumb" src="http://rumishop2/image/cache/no_image-100x100.png" width="40" height="40" alt="" /> <span class="text">Web Cameras</span></a> </li> </ul> </div>
It's the source of the Ctrl+U code, you bet... As you can see here... That the code creates a yol every five, but first of all, it's not 1 level with
<ul class="children-list children-list-col clearfix">
and inside it... And in addition to everything, is there any reason to be created in the main yol.
Please help me and pardon me. ♪
-
Replace:
<?php $k=0; foreach ($children as $child) {(($k%5==0) ? "</ul><ul>" :"");?>
On:
<?php $k=0; foreach ($children as $child) { if($k%5==0) { echo "</ul><ul>"; } $k++;?>