0

I'm working on a website that creates an object called player that can contain any number of event objects that get added to the player object from an event-driven xml parser. So what I've been trying to do is use an array but that does not working, from my understanding this is because arrays must be constructed at object creation. So anyone have any alternative ideas or thoughts on what I missed?

<?php 

class player {
	//removed unrelated variables
	var $attendance;

	//removed unrelated functions
	function player() { }
	
	function addEvent(&$event) {
		$this->attendance[] = $event;
	}
}
?>

Edited by rcalt2vt: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by JRM
0

Someone else already said it better than I could...

http://www.daniweb.com/forums/thread130759.html

Ya, I've been over that post several times. It doesn't help too much with my situation since in his code he passed in the array when he instanced the object and also provided an example of accessing a global array.

Neither of which work for what I am working on. As I mentioned I need to add elements to an array inside of an already instanced object. I could achieve the same effect by implementing a linked list data structure inside the object, however I would hate to do that only to find out later that an array will work and I just used it wrong. Which brings me back to the topic:
Is there anyway to add additional elements to an array inside of an already instanced object?

0

Then you need it to be global and static?
If you are doing stuff on the fly, wouldn't Javascript be a better choice?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.