To get a part of an array, you can use array_slice:
$input = array("a", "b", "c", "d", "e");
$len = (int) count($input);
$firsthalf = array_slice($input, 0, $len / 2);
$secondhalf = array_slice($input, $len / 2);
Related Contents:
- How can I sort arrays and data in PHP?
- Can I bind an array to an IN() condition in a PDO query?
- How to sort an array of associative arrays by value of a given key in PHP?
- Multiple inputs with same name through POST in php
- Two arrays in foreach loop
- Modify array values in foreach loop
- How to check if PHP array is associative or sequential?
- PHP Sort Array By SubArray Value
- Get first key in a (possibly) associative array?
- How to find entry by object property from an array of objects?
- glob() – sort array of files by last modified datetime stamp
- PHP Array to JSON Array using json_encode(); [duplicate]
- How to filter a two dimensional array by value
- How to insert element into arrays at specific position?
- Convert array of single-element arrays to one a dimensional array
- PHP – Merging two arrays into one array (also Remove Duplicates)
- How to use a string as an array index path to retrieve a value?
- PHP Difference between array() and []
- php implode (101) with quotes
- More concise way to check to see if an array contains only numbers (integers)
- Echo a multidimensional array in PHP
- Rotate array elements to the left (move first element to last and re-index)
- Group array data on one column and sum data from another column
- How is the PHP array implemented on the C level?
- Transpose 2d array, join second level with commas, and join first level with pipes
- Remove all elements from array that do not start with a certain string
- How to sort a multidimensional array by a certain key?
- Sort an array by a child array’s value in PHP
- PHP Objects vs Arrays — Performance comparison while iterating
- Merge row data from multiple arrays
- PHP Random Shuffle Array Maintaining Key => Value
- php return only duplicated entries from an array
- Looping a multidimensional array in php
- Casting an Array with Numeric Keys as an Object
- Shorthand for arrays: is there a literal syntax like {} or []?
- Get week number in month from date in PHP?
- Returning Multiple Rows with MySqli and Arrays
- Split array into two arrays by index even or odd
- Select from mysql table WHERE field=’$array’?
- Isolate comma-separated values, remove duplicates and empty values, then sort
- Check whether an array is empty [duplicate]
- How to implode array with key and value without foreach in PHP
- PHP get the last 3 elements of an associative array while preserving the keys?
- How can I use in_array if the needle is an array?
- How to access a property of an object (stdClass Object) member/element of an array? [duplicate]
- How do I `json_encode()` keys from PHP array?
- Merge two multidimensional arrays and reindex all subarrays
- PHP – Find parent key of array
- PHP: Check for duplicate values in a multidimensional array
- Custom key-sort a flat associative based on another array