Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php slice array in half

$halved = array_chunk($books, ceil(count($books)/2));
Comment

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
";
  }
}
Comment

PREVIOUS NEXT
Code Example
Php :: drupal get node id from twig 
Php :: php file upload ajax 
Php :: how to upload large video file in php 
Php :: pdo mysqli error handling 
Php :: laravel login shows 404 
Php :: php function to remove 0 value from array 
Php :: php string to date 
Php :: session forget laravel 
Php :: php multiplication 
Php :: php contain 
Php :: how to assign variable in php 
Php :: microft access request database with pdo 
Php :: strrev php 
Php :: laravel has many with ids 
Php :: laravel tinker insert db record 
Php :: Displaying Custom Navigation Menus in WordPress Themes 
Php :: remove all items of an array except the last 5 in php 
Php :: wordpress args 
Php :: laravel collection to json 
Php :: echo php in html 
Php :: wc get product category image 
Php :: php library to convert html to amp 
Php :: math functions and predefined constants php 
Php :: laravel relationship delete all 
Php :: epoch conversion php 
Php :: laravel adding condition to relation 
Php :: wordpress post add input field 
Php :: PDO Prepared Statement php 
Php :: how to use uuid in laravel model 
Php :: show uploaded image in php 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =