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
Solved

Recursive walk through array and change values?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

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 …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

837 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