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

  • SEARCH
  • Home
  • 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 4024780
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:45:51+00:00 2026-05-20T10:45:51+00:00

function heaviside(&$value, $key, &$array) { if($key > 0) $value = $array[$key-1].$array[$key]; } function test_heaviside()

  • 0
    function heaviside(&$value, $key, &$array)
    {
            if($key > 0)
            $value = $array[$key-1].$array[$key];
    }

    function test_heaviside()
    {
            for($i=0; $i<10; $i++)
            {
                    $array[$i] = $i;
            }
            array_walk($array, 'heaviside', &$array);
            print_r($array);
    }

    test_heaviside();

My problem is that the above code will generate this warning:

PHP Warning: Call-time
pass-by-reference has been deprecated
– argument passed by value; If you would like to pass it by reference,
modify the declaration of
array_walk(). If you would like to
enable call-time pass-by-reference,
you can set
allow_call_time_pass_reference to true
in your INI file. However, future
versions may not support this any
longer.

And if I remove & in &$array in my call to array_walk, this function will not return this correct result. In the first case, where it works, it returns this result:

[0] => 0
[1] => 01
[2] => 012
[3] => 0123
[4] => 01234
[5] => 012345
[6] => 0123456
[7] => 01234567
[8] => 012345678
[9] => 0123456789

Whereas if I remove & it returns:

[0] => 0
[1] => 01
[2] => 12
[3] => 23
[4] => 34
[5] => 45
[6] => 56
[7] => 67
[8] => 78
[9] => 89

I need help understanding this or simply to find a solution other than changing .ini.

  • 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-05-20T10:45:51+00:00Added an answer on May 20, 2026 at 10:45 am

    You’re abusing array_walk here — your callback function isn’t actually returning the new value. array_walk is intended to work with one and only one value from the target array, and can not work with anything by reference.

    You can achieve the effect you’re looking for by using a simple for loop:

    // Set up the array.
        $array = array();
        for($i = 0; $i < 10; $i++)
            $array[$i] = $i;
    // Process it, starting at the second element
        for($i = 1; $i < count($array); $i++)
            $array[$i] = $array[$i - 1] . $array[$i];
        print_r($array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function simple_form($form_state) { $form['item'] = array('#type' => 'hidden', '#value' => 'some_value'); $form['#action'] = 'http://external-website.com/';
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) {
What function will let us know whether a date in VBA is in DST
function manageVoting() { var parameter; var myVoting; var divVoting; var divVotes; var value =
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function main() { Hello(); } function Hello() { // How do you find out
function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError,
function holiday_hitlist($tablename, $hit_user){ global $host, $user, $pass, $dbname; $link = mysql_connect($host, $user, $pass, $dbname);

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.