Solved

Recursive walk through array and change values?

Posted on 2009-05-13
1
861 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
1 Comment
 
LVL 7

Accepted Solution

by:
Jonah11 earned 230 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now