Solved

Recursive walk through array and change values?

Posted on 2009-05-13
1
870 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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.

863 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

28 Experts available now in Live!

Get 1:1 Help Now