Solved

Recursive walk through array and change values?

Posted on 2009-05-13
1
899 Views
Last Modified: 2012-05-06
I want to go through a multilevel deep array and change(fix) some values. I know i can go through array using array_walk_recursive, but i cant manage to change values(to uppercase) to the original array but in all lavels.

Can someone help me please?
0
Comment
Question by:kzdown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Jonah11 earned 230 total points
ID: 24382244
Code below should convert all levels of the array to uppercase.
function makeUpper(&$value, $key) {
  $value = strtoupper($value);
}
 
array_walk_recursive($nestedArray, 'makeUpper');

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 100
Wordpress Query 5 42
Inserting results of While loop to sql server 5 34
How to use session variables in php? 22 42
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question