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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:14:00+00:00 2026-05-24T22:14:00+00:00

Why are just a few PHP array functions are available in ArrayObject class as

  • 0

Why are just a few PHP array functions are available in ArrayObject class as method? For example asort() is available but walk() and many others are not.

$s= new ArrayObject(array(1,3,4,5,6,4));
$x= $s->asort();                   //implemented
$x= $s->sum();                     //not implemented
$x= array_sum($s->getArrayCopy()); //not an OO manner!  
//sum is an example, consider:array_map,array_walk,array_merge .... 

Please note that I have carefully read the documentation. My question is WHY php team just embedded a subset of array functions in ArrayObject class (that should encapsulate array related requirments). Isn’t it a poor design?
Why we should extend this class and embed tens of function in this class again? Is is reasonable?

  • 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-24T22:14:01+00:00Added an answer on May 24, 2026 at 10:14 pm

    Think about what a collection of objects should be able to do natively and easily. If I have a collection of books, I want to be able to sort them, I want to be able to get one at a certain location, I want to be able to iterate through them, etc. What I don’t want is to be able to add them all up. If I added a sum function to that object, it would mean that every instance of that object would also have a sum function — a bizarre and unexpected use case for the most part.

    ArrayObject, in a lot of senses, is a lot closer to the idea of the traditional array than PHP’s array ever managed. I believe it is supposed to be faster because of this.

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

Sidebar

Related Questions

Hi guys I have to port a few functions from AS to PHP, but
I have a php array of primary key values, which correspond to just a
just starting with cakephp and almost with php after a few years without use
I added a function in my .vimrc that's just few search and replace commands.
I'm almost done with this, just a few last hiccups. I now need to
I need to take an existing xml file, and modify just a few attributes
MVC is used a number of popular frameworks. To name just a few, Ruby
I just came across few articles, while selecting a wiki for my personal site.
i've just read a few posts on hiding Silverlight code in some way. Main
I need to make changes to an in-use production database. Just adding a few

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.