Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

array_walk_recursive(3) [php man page]

ARRAY_WALK_RECURSIVE(3) 						 1						   ARRAY_WALK_RECURSIVE(3)

array_walk_recursive - Apply a user function recursively to every member of an array

SYNOPSIS
bool array_walk_recursive NULL (array &$array, callable $callback, [mixed $userdata]) DESCRIPTION
Applies the user-defined $callback function to each element of the $array. This function will recurse into deeper arrays. PARAMETERS
o $array - The input array. o $callback - Typically, $callback takes on two parameters. The $array parameter's value being the first, and the key/index second. Note If $callback needs to be working with the actual values of the array, specify the first parameter of $callback as a refer- ence. Then, any changes made to those elements will be made in the original array itself. o $userdata - If the optional $userdata parameter is supplied, it will be passed as the third parameter to the $callback. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 array_walk_recursive(3) example <?php $sweet = array('a' => 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); function test_print($item, $key) { echo "$key holds $item "; } array_walk_recursive($fruits, 'test_print'); ?> The above example will output: a holds apple b holds banana sour holds lemon You may notice that the key ' sweet' is never displayed. Any key that holds an array will not be passed to the function. SEE ALSO
array_walk(3), information about the callback type. PHP Documentation Group ARRAY_WALK_RECURSIVE(3)

Check Out this Related Man Page

ARSORT(3)								 1								 ARSORT(3)

arsort - Sort an array in reverse order and maintain index association

SYNOPSIS
bool arsort (array &$array, [int $sort_flags = SORT_REGULAR]) DESCRIPTION
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. PARAMETERS
o $array - The input array. o $sort_flags - You may modify the behavior of the sort using the optional parameter $sort_flags, for details see sort(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 arsort(3) example <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); arsort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val "; } ?> The above example will output: a = orange d = lemon b = banana c = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained. SEE ALSO
asort(3), The comparison of array sorting functions. PHP Documentation Group ARSORT(3)
Man Page

15 More Discussions You Might Find Interesting

1. Programming

HELP (server?)

Could anyone provide me with the source code for a simple multithreaded server in C that uses UNIX system calls, implementing only the GET command. Or point me to a location where I can view such source code? any help will save my bacon! Regards Gee :( (4 Replies)
Discussion started by: Gee
4 Replies

2. UNIX for Dummies Questions & Answers

wall

is there a command to send all terminals a message. i tired wall, but it only sends the message to who ever is logged in at a terminal. i need a command to send to every terminal no matter if someone is logged in or not. Thanks! -The DJ (11 Replies)
Discussion started by: djatwork
11 Replies

3. Shell Programming and Scripting

$# question

$# holds the number of arguments passed into a shell. Is this value the index of an array? and if so, is there a way to determine the max index of the array so that I can know right off how many values were passed in? or do I have to sit in some sort of loop testing to see if $# is set,... (2 Replies)
Discussion started by: google
2 Replies

4. UNIX for Dummies Questions & Answers

Simple? Search replace

in vi, if i type ctrl-J, i can shift the next line up to the current line. I need to do this whenever a specific string exists (in particular ^M) ,however i have not been able to find a way to do this in vi, sed, or awk seems simple enough. can someone help me? thanks in advance (9 Replies)
Discussion started by: Brandt
9 Replies

5. Shell Programming and Scripting

How to declare hashes in KSH similar to Perl ?

Hi, Is it possible to delcare hashes in KSH the way we do it in Perl. Like I want to declare something like: fruits="Juicy" fruits="healthy" fruits="sour" echo fruits Ofcourse this piece of code does not work in KSH. Please let me know if there is a way of doing it in KSH. ... (2 Replies)
Discussion started by: tipsy
2 Replies

6. Shell Programming and Scripting

find an available item in array

Dear all, I'm have a sorted array like this: 177 220 1001 2000 2001 2003 2005 notice that 2002 and 2004 are NOT in array. Then user input a number INPUT, our script should return OUTPUT value like this: if INPUT is not in array => OUTPUT=INPUT if INPUT is in array => OUTPUT is the... (4 Replies)
Discussion started by: fongthai
4 Replies

7. Shell Programming and Scripting

parse by string and difference in substring???

I have a big list as the following: apple X:5_yes_a apple X:12_no_b apple X:45_yes_a apple X:100_no_b banana X:7_yes_a banana X:13_yes_a banana X:42_no_a cat X:42_no_b cat X:77_yes_d I'd like to parse the file so that for each $1 value I return only lines in which the value in $2... (4 Replies)
Discussion started by: dcfargo
4 Replies

8. UNIX for Dummies Questions & Answers

Unix Forms

Hi Im new so be gentle Just starting out in programing and i want to try unix to see what all the fuss is about. But right now im like a kid in a sweet shop, spoilt for choice. Theres red hat, fedora, linux, ubuntu and thats just for starters I've been told ubuntu is a nice... (3 Replies)
Discussion started by: NightWatchman
3 Replies

9. Shell Programming and Scripting

How to apply brackets?

Hi, I have a query term like this: $query="apple NOT banana AND fruits"; $query="a1 NOT prim1 AND a2 NOT a3 OR a5"; I want to apply brackets to the NOT terms and the output should be like this: $query="apple NOT (banana) AND fruits"; $query="a1 NOT (prim1) AND a2 NOT (a3) OR a5";... (2 Replies)
Discussion started by: vanitham
2 Replies

10. UNIX for Dummies Questions & Answers

checking if parameter passed is a number

I have written a function that fills an array and another function where if a parameter is supplied it will jump to that part of the array and cat it to the screen. I need to put in some checks to make sure the parameter supplied is firstly a number and then not a number great than the length of... (2 Replies)
Discussion started by: magnia
2 Replies

11. UNIX for Advanced & Expert Users

Urgent! need help! how to convert this file into comma delimited format

Hi experts, I need urget help! I have the a text file with this format: Types of fruits Name of fruits 1,1 Farm_no,1 apple,1 pineapple,1 grapes,1 orange,1 banana,1 2,2--->this is the record seperator Farm_no,2 apple,1 pineapple,1 grapes,3 orange,2 banana,1 3,3--->this is the... (2 Replies)
Discussion started by: natalie23
2 Replies

12. Shell Programming and Scripting

[bash] passing array to function

Hi, I'm trying to write a function that reassigns an array to another local array but the method used in reassigning the array reformats the contents of the array which is what I am trying to prevent. The method used to load a file into an array works as expected and the entire array is... (4 Replies)
Discussion started by: ASGR
4 Replies

13. Programming

how to put element of an array to first position.

hi, I have a array like my $array = ( "apple","ball","cat","dog","elephant"); how to push some element in the array to the first position. for example my final array should be elephant apple ball cat dog (5 Replies)
Discussion started by: vprasads
5 Replies

14. Shell Programming and Scripting

How to get next string of a matching string?

fruits="apple grape orange jack lemon" I want the element present next to "orange". i.e. jack Note: The position of orange is not fixed. fruits="apple grape orange jack lemon" echo $fruits | awk '{ for ( n=1; n<=NF; n++ ) if($n ~ my_string) print $n }' my_string="orange" This will... (2 Replies)
Discussion started by: Arun_Linux
2 Replies

15. Shell Programming and Scripting

Replace query by reading the file

Hi Guys, I am having below file which holds data like this file.txt name,id,flag apple,1,Y apple,2,N mango,1,Y mango,2,Y I need to read the above file and frame a query like this hive -s -e "create apple_view as select 1 from main_table;" hive -s -e "create mango_view as select... (11 Replies)
Discussion started by: rohit_shinez
11 Replies