Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

array_chunk(3) [php man page]

ARRAY_CHUNK(3)								 1							    ARRAY_CHUNK(3)

array_chunk - Split an array into chunks

SYNOPSIS
array array_chunk (array $array, int $size, [bool $preserve_keys = false]) DESCRIPTION
Chunks an array into arrays with $size elements. The last chunk may contain less than $size elements. PARAMETERS
o $array - The array to work on o $size - The size of each chunk o $preserve_keys - When set to TRUE keys will be preserved. Default is FALSE which will reindex the chunk numerically RETURN VALUES
Returns a multidimensional numerically indexed array, starting with zero, with each dimension containing $size elements. ERRORS
/EXCEPTIONS If $size is less than 1 E_WARNING will be thrown and NULL returned. EXAMPLES
Example #1 array_chunk(3) example <?php $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 2)); print_r(array_chunk($input_array, 2, true)); ?> The above example will output: Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) ) Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [2] => c [3] => d ) [2] => Array ( [4] => e ) ) SEE ALSO
array_slice(3). PHP Documentation Group ARRAY_CHUNK(3)

Check Out this Related Man Page

ARRAY_COMBINE(3)							 1							  ARRAY_COMBINE(3)

array_combine - Creates an array by using one array for keys and another for its values

SYNOPSIS
array array_combine (array $keys, array $values) DESCRIPTION
Creates an array by using the values from the $keys array as keys and the values from the $values array as the corresponding values. PARAMETERS
o $keys - Array of keys to be used. Illegal values for key will be converted to string. o $values - Array of values to be used RETURN VALUES
Returns the combined array, FALSE if the number of elements for each array isn't equal. ERRORS
/EXCEPTIONS Throws E_WARNING if the number of elements in $keys and $values does not match. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.4.0 | | | | | | | Previous versions issued E_WARNING and returned | | | FALSE for empty arrays. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 A simple array_combine(3) example <?php $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?> The above example will output: Array ( [green] => avocado [red] => apple [yellow] => banana ) SEE ALSO
array_merge(3), array_walk(3), array_values(3). PHP Documentation Group ARRAY_COMBINE(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Array Retrieval Formatting

I have a shell script (Solaris v8 ksh) loading an array from a flat file. An exaple of that flat file is below. It contains white-spaces, and carrage returns. When I try to load the first line as a variable, it (the variable) shows up as the first field not the first line. How do you arrange an... (9 Replies)
Discussion started by: gozer13
9 Replies

2. Programming

Sorting in C++..

Hi, I need to do a sorting of 2 arrays. One array contains the values of both integer and character and other array can be anything. For example: Array={'1L','2C','NULL','23L','11L','4C','10L','9C'} Array= {'01-02-13-1x','02-11-23-3s','00-12-13-5f','NULL','22k',} If any of these arrays... (6 Replies)
Discussion started by: ronix007
6 Replies

3. Shell Programming and Scripting

Store values in an Array

Hi all. Well, I have the next code: I need to make an array with the values I have in the bucle, but just don't get it... Question is, how can I store in an array that values, and how can I display them with echo? (8 Replies)
Discussion started by: crcbad
8 Replies

4. Shell Programming and Scripting

Array manipulation in perl

hi all, i am trying to append the output of a find command (for different paths)in an array as below... my $res_array; $i=0; $dir="/orn/ops/regs"; foreach $block("am","xb"){ $bdir="$dir/$block"; $res_array=`find $bdir ! -user mainuser -printf \"\%u \%h\\n\"`; $i++; } i... (6 Replies)
Discussion started by: saapa
6 Replies

5. Shell Programming and Scripting

Array as argument

hi I've 2 bash script, in the first i define an array and I'd like to pass it as argument to the second script. For example: first_bash: k=(1 2 3 4) ....... #in the end i call the 2 script ./second_bash $k then in the second_bash: ..... echo "${1}" #this not work but i'm... (7 Replies)
Discussion started by: Dedalus
7 Replies

6. Shell Programming and Scripting

Array reference problem

i have a variable MYHOST that has my host name.depending on the host i have an array like A_<hostname>.Everytime i need to append the hostname to A_ to get the array.but in the shell script i am nt able to access the members of that array. code of what i hav done: export temp=A_$MYHOST for... (15 Replies)
Discussion started by: niteesh_!7
15 Replies

7. Shell Programming and Scripting

Help with manipulating Array in Perl

I am new in perl .... I defined Array in Perl which contain values as below: Array name: @TEST sample values : when I print Array: print " @test \n"; <title>0008857661</title> <title>0009841171</title> <title>0010161261</title> <title>0010230023</title> I want to get only these... (7 Replies)
Discussion started by: gdubey
7 Replies

8. Programming

Array and Vector

Hi all, from my understanding I understand that I can use array in this manner. struct test { int a; int b; int c; }; test testing; //creating an array with the structer type testing.a=1; testing.b=2; testing.c=3; If I'm not wrong we can use array in this manner,... (12 Replies)
Discussion started by: vinzping
12 Replies

9. Solaris

Storage Array not readable

Hi We have an array connected to the machine but when i issue format command i dont see it. But the array is up and running and there are no warning lights. Is there a way to find that array from the OK boot prompt? Please advise. Thanks (9 Replies)
Discussion started by: prash358
9 Replies

10. Shell Programming and Scripting

Syntax error near unexpected token '('

I tried to execute the code but I got this error ./Array.c: line 9: syntax error near unexpected token '(' ./Array.c: line 9: ' nvals = get_data(a,MAXARRAY);' and #include<stdio.h> #define MAXARRAY 1000 main() { int a, nvals; nvals =... (7 Replies)
Discussion started by: sgradywhite
7 Replies

11. Shell Programming and Scripting

Passing argument 1 of 'scanf' makes po

$ cc Array.c Array.c: In function ‘main’: Array.c:23: warning: passing argument 1 of ‘scanf’ makes po Array.c:25: error: expected expression before ‘return’ Array.c:29: error: expected expression before ‘return’ Array.c: At top level: Array.c:44: error: expected ‘)’ before ‘&’ token... (8 Replies)
Discussion started by: sgradywhite
8 Replies

12. Shell Programming and Scripting

Arrays in awk

Array A contains lines of numbers from files. Array B contains number of fields for each line of each file. I want to run on array A. To do that I need to know the number of fields for each file in array A (because each line doesn't have the same NF). The NF is in array B, problem is: I don't... (6 Replies)
Discussion started by: guitarist684
6 Replies

13. Programming

Array Elements Check

Hi everyone, :) I'm trying to make a simple C program that scans an array of chars to see if its elements are similar. I can't understand what's wrong. Could you help me to fix this? Here is the code. Thanks! #include<stdio.h> int main() { int arr; int i, len; int flag =... (10 Replies)
Discussion started by: IgorGest
10 Replies

14. Shell Programming and Scripting

Array to array scanning

trying a little bit of array scanning for open ports. my code looks like below: /bin/netstat -lntp|\ awk 'BEGIN { split("25 80 2020 6033 6010",q); } $1 == "tcp" { split($4,a,":"); p]++; } $1 == "tcp6" { split($4,a,":");p]++ } END { for ( i in q ) { if (! q in p ) {... (8 Replies)
Discussion started by: busyboy
8 Replies

15. Shell Programming and Scripting

Sort multidimensional Array

Hello I have a problem. I create a Multidimensional Array Like this: ENTRY="$kunnum-$host" ENTRY="$host" ENTRY="# $3" for key in "${!ENTRY}"; do ENTRIES=${ENTRY} # INDEX=IP(5) donedeclare -p declare -A ENTRIES=(="unas15533" ="unas" ="# RDP-Terminal 2"... (12 Replies)
Discussion started by: Marti95
12 Replies