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);
More Related Contents:
- How to make array inside in foreach loop – php? [closed]
- How do search array values and remove them based on a condition or string? [closed]
- How can I sort arrays and data in PHP?
- How to Flatten a Multidimensional Array?
- Sort array of objects by object fields
- Get the first element of an array
- + operator for array in PHP?
- How to create an array from a CSV file using PHP and the fgetcsv function
- How to reindex an array?
- array_splice() for associative arrays
- Is it necessary to declare PHP array before adding values with []?
- Explode a string to associative array without using loops? [duplicate]
- Casting an Array with Numeric Keys as an Object
- How to trim white spaces of array values in php
- How to get all combinations from multiple arrays?
- PHP Array Syntax Parse Error Left Square Bracket “[” [closed]
- What’s the difference between array_merge and array + array? [duplicate]
- How do I use array_unique on an array of arrays?
- How to count non-empty entries in a PHP array?
- How to implode array with key and value without foreach in PHP
- PHP array replace after matching value [duplicate]
- MySQL query using an array [duplicate]
- PHP get previous array element knowing current array key
- Convert a String to Variable
- How do I select 10 random things from a list in PHP?
- How to iterate through a nested stdClass? [duplicate]
- How to get the object or class name?
- PHP convert nested array to single array while concatenating keys?
- Group array data on one column and sum data from another column to form a flat associative array
- Convert delimited string into array key path and assign value