Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:34:58+00:00 2026-06-08T08:34:58+00:00

PHP has some great functions (like array_walk) that allow you to process each element

  • 0

PHP has some great functions (like array_walk) that allow you to process each element in an array. They’re generally set up so you specify the array you want processed as the first parameter and a callback function to apply to each element as the second. These functions return booleans indicating success, not a copy of the modified array as you might expect. If you want the array to be modified, you have to pass the array in by reference like array_walk(&$my_array, 'my_callback');

However, in PHP 5.3 and above, if you pass by reference to function call you get a E_DEPRECATED error.

Does anyone know (if there exists) a correct way to use these functions to modify arrays without triggering the errors and without explicitly suppressing them? Are there newer alternatives to these old array processing functions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:35:00+00:00Added an answer on June 8, 2026 at 8:35 am

    Values are passed by reference implicitly in PHP >= 5.3 as determined by the function definition.

    Function definition for array_walk():

    bool array_walk ( array &$array , callable $funcname [, mixed $userdata = NULL ] )
    

    Note &$array. As such, you do not need to explicitly pass the array by reference in the function call in PHP >= 5.3.

    array_walk($my_array, 'my_callback');
    

    However, you will need to ensure that the callback accepts it’s value by reference accordingly (as demonstrated by nickb).

    Also take a look at PHP 5.4 Call-time pass-by-reference – Easy fix available?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP has some pretty inconsistent parameters for functions (e.g. sometimes first haystack , then
I have a php file which has some variables like $name1, $name2... How can
NetBeans has some great features in it like auto-generating code. However there are some
I am working on a PHP-Mysql based website which has some large lists to
A long shot but here's hoping someone has some experience coding PHP hooks for
PHP 5.3 has been released some time ago and the developers tried to keep
I am developing an app in PHP and at some points the app has
PHP has PHP-FPM, a pool of PHP processes that run, are managed, go away
Php has a method escapeshellcmd() that escapes any characters in a string that might
Would be great if you guys could shed some light on this, has baffled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.