Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php slice array in half

<?php
$input_array = array('a', 'b', 'c', 'd', 'e', 'f');
$arrays = array_chunk($input_array, 3);

foreach ($arrays as $array_num => $array) {
  echo "Array $array_num:
";
  foreach ($array as $item_num => $item) {
    echo "  Item $item_num: $item
";
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #slice #array
ADD COMMENT
Topic
Name
7+7 =