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 1104381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:28:31+00:00 2026-05-17T01:28:31+00:00

So I want to extend for example this RecursiveIterator from the SPL with the

  • 0

So I want to extend for example this RecursiveIterator from the SPL with the function each so i can easily walk over the object/array

class it extends RecursiveArrayIterator {
    public function each( $function, $args=array() ){
        $args = (sizeof($args)>0) ? array_merge(array($this),(array)$args) : array($this);
        iterator_apply( $this, $function, $args );
        return $this;
    }
}
//Running it:
$it = new it( &$array );
$it->each( function( $it ){
    $it->offsetSet( $it->key(),  $it->current() + 1 );
    return true;
});

Which results in:

Deprecated: Call-time pass-by-reference has been deprecated in …

The problem is i can’t, or shouldn’t, use the reference when creating the object because its depricated. But when iterating over the array/object i want to be able to make changes to it, how can i achieve this without changing the allow_call_time_pass_reference to On? I’m using wamp with php 5.3.

Have a nice day

1: http://www.php.net/manual/en/class.recursivearrayiterator.phpin …

  • 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-17T01:28:32+00:00Added an answer on May 17, 2026 at 1:28 am

    You would have to change the constructor to take the variable by reference; but that’s not possible here, because even if you changed the constructor for your class, you’d still have to call the parent constructor, which doesn’t take by reference.

    The solution would have to involve changing the signature of ArrayIterator::__construct to receive the array by reference.

    In principle, you would be able to override the call-time pass-by-reference limitation with call_user_func_array, however that doesn’t work with internal functions (in this case, ArrayIterator::__construct); see bug #52940.

    This does not work:

    public function __construct(&$array) {
        call_user_func_array('parent::__construct', array(&$array));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extend the example called Object ListModel Example from Qt documentation (you
I want to extend RuntimeException to create this specific exception: class CompileLinkException extends RuntimeException
I want to extend the IEnumerable class but only for types that can be
Folks I have a sealed class as follows. I want to extend this sealed
I want to extend a class as shown in the below example. While extending,
I've got this to work using a very basic example(outlined below) and I want
I want to extend Object.prototype, to basically support notifications in JSON data and html
I want to extend the basic ControlCollection in VB.NET so I can just add
I want to extend my EF class with additional property that would come from
I have a jQuery function (stripped down just for this example): (function($) { $.fn.Lightbox

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.