Greetings to all PHP gurus out there! Since I'm fairly new to php programming I have a question for you all. I have an array of objects, each object has a unique id property. What is the best way to alter some properties of that particular object?

I guess I would use the object's ID as the key in your array, so you can quickly find and use it. Is it possible to build the array this way?

Micky

thx for your reply, what im trying to do is update some object properties and keep that object in that array. in other words i want the change of the object properties reflected in the array.

OK, then you wouldn't need the objects, id, you can simply loop through the objects:

foreach(objArray as obj){
  obj->attrToBeChanged = newValue;
}

I hope i understand your question right.

Micky

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.