Skip to content

Instantly share code, notes, and snippets.

@Shipu
Last active September 19, 2017 21:08
Show Gist options
  • Save Shipu/e91956db869365dcc24905e7673091d6 to your computer and use it in GitHub Desktop.
Save Shipu/e91956db869365dcc24905e7673091d6 to your computer and use it in GitHub Desktop.
Dynamic Splits Array like as "array_chunk()"
<?php
$data = [10,2,32,41,21,18,17,6,59];
$arraySize = count($data);
$chunkSize = 2;
echo "<div class='own-countersoul'>";
for($i = 0; $i < $arraySize; ) {
echo "<div class='item'>";
for($j = 0; $j < $chunkSize && $i < $arraySize ; $j++, $i++) {
echo "<div class='single_item'>".$data[$i]."</div>";
}
echo "</div>";
}
echo "</div>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment