Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

array_flip(3) [php man page]

ARRAY_FLIP(3)								 1							     ARRAY_FLIP(3)

array_flip - Exchanges all keys with their associated values in an array

SYNOPSIS
array array_flip (array $array) DESCRIPTION
array_flip(3) returns an array in flip order, i.e. keys from $array become values and values from $array become keys. Note that the values of $array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result. If a value has several occurrences, the latest key will be used as its value, and all others will be lost. PARAMETERS
o $array - An array of key/value pairs to be flipped. RETURN VALUES
Returns the flipped array on success and NULL on failure. EXAMPLES
Example #1 array_flip(3) example <?php $input = array("oranges", "apples", "pears"); $flipped = array_flip($input); print_r($flipped); ?> The above example will output: Array ( [oranges] => 0 [apples] => 1 [pears] => 2 ) Example #2 array_flip(3) example : collision <?php $input = array("a" => 1, "b" => 1, "c" => 2); $flipped = array_flip($input); print_r($flipped); ?> The above example will output: Array ( [1] => b [2] => c ) SEE ALSO
array_values(3), array_keys(3), array_reverse(3). PHP Documentation Group ARRAY_FLIP(3)

Check Out this Related Man Page

ARRAY_COUNT_VALUES(3)							 1						     ARRAY_COUNT_VALUES(3)

array_count_values - Counts all the values of an array

SYNOPSIS
array array_count_values (array $array) DESCRIPTION
array_count_values(3) returns an array using the values of $array as keys and their frequency in $array as values. PARAMETERS
o $array - The array of values to count RETURN VALUES
Returns an associative array of values from $array as keys and their count as value. ERRORS
/EXCEPTIONS Throws E_WARNING for every element which is not string or integer. EXAMPLES
Example #1 array_count_values(3) example <?php $array = array(1, "hello", 1, "world", "hello"); print_r(array_count_values($array)); ?> The above example will output: Array ( [1] => 2 [hello] => 2 [world] => 1 ) SEE ALSO
count(3), array_unique(3), array_values(3), count_chars(3). PHP Documentation Group ARRAY_COUNT_VALUES(3)
Man Page

14 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies

2. Shell Programming and Scripting

Array Declaration and For Loop

I am just stucked in syntax.This is more like a array and for loop problem. I want to use ls -l command and get filezise and filename of all filenames in the directory in an array (say array#1). After 2 minutes of sleep, i want to get the same information in another array (say array#2). The... (4 Replies)
Discussion started by: 33junaid
4 Replies

3. Shell Programming and Scripting

Array operation

Hi, I would like ask for you help for coding array operation. array= ( a b c d e f ) I would like to remove entry "d" from my array and import the remaining entries back to the array. Thanks. (3 Replies)
Discussion started by: phamp008
3 Replies

4. UNIX for Dummies Questions & Answers

How to store the values in a file into an array

Hi, I do have a file and the contents are as follws: 10 20 30 40 50 Now I want to store those values into an array. How can be done this ?? (3 Replies)
Discussion started by: risshanth
3 Replies

5. Shell Programming and Scripting

Array help

Hi all, I have the scenario where i have different categories of servers of 4 pairs, like pairA=4 serves,pairB=4 servers like that. I want to store them in an array with their hostnames, depends on that hostname iam running this script if that falls in any array the script should do something. ... (4 Replies)
Discussion started by: Jartan
4 Replies

6. Programming

Rotate an array

i have an array a={1,2,3,4,5} the output should be a= {4,5,1,2,3} please help me writin this program in c. (10 Replies)
Discussion started by: pgmfourms
10 Replies

7. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

8. Shell Programming and Scripting

space not allowed in input

I have this script. (options is an array) It works fine. It responds fine to all items that are stored in the array. But when I press spacebar when I am asked for input. It will not give an error only run the function again. While I put : || ] in the script to capture the space. What am I missing... (6 Replies)
Discussion started by: Alex400
6 Replies

9. Programming

Signalsafe data structures

Hello, I have a signal handler which manipulates a data structure. The data structure's operations aren't atomic. So if two threads/processes are in a critical section at the same time the data structure will be broken. With threads you can avoid this stuff with semaphores etc. However,... (10 Replies)
Discussion started by: littlegnome
10 Replies

10. Shell Programming and Scripting

How to read values and store in array?

I am reading a value from a file and want to store the value in a dynamic array as i don't know the number of occurrences of the value in that file. How can i do that and then later fetch that value from array (25 Replies)
Discussion started by: Prachi Gupta
25 Replies

11. UNIX for Dummies Questions & Answers

Combine lines from file

Hello, Input file looks like this: apples bananas oranges and rice pears cherries mango I want output to look like this: apples bananas oranges and rice pears cherries mango It should combine line 1 with line 2 and line 3 with line 4 like that.... Right now, only way I can... (4 Replies)
Discussion started by: holyearth
4 Replies

12. Shell Programming and Scripting

problem in binning the data

hi i have some data like this input: 1 apples oranges 234 2 oranges apples 2345 3 grapes bananas 1000000 4 melons banans 10000000 5 bananas apples 5000000 6 mangoes banans 2000000 7 apples bananas 1999999 i want to put all those which are coming between 1 and 999999 in to one bin... (8 Replies)
Discussion started by: anurupa777
8 Replies

13. 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

14. Shell Programming and Scripting

Multidimensional array

I am learning about bash system variables, such as $ , @ and #. I have this piece of script implementing an array and it is doing its job just fine. This is not the only array I will be using. Just for ease of maintenance and more coding I would like to have the arrays in two dimensional... (4 Replies)
Discussion started by: annacreek
4 Replies