action Posted September 8, 2010 Share Posted September 8, 2010 hi, i would like to find out if anyone has any examples of code for a collection class(alternative to array) thanks Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/ Share on other sites More sharing options...
AbraCadaver Posted September 8, 2010 Share Posted September 8, 2010 Can you be a little more specific/descriptive? Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108774 Share on other sites More sharing options...
action Posted September 8, 2010 Author Share Posted September 8, 2010 There is a brief introduction on: http://www.nomadhacker.com/uncategorized/creating-a-php-collection-class/comment-page-1/#comment-1319 i need to create a collection class with students,(add/delete,etc) but it must be using the "collection class" concept. Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108781 Share on other sites More sharing options...
AbraCadaver Posted September 8, 2010 Share Posted September 8, 2010 There is a brief introduction on: http://www.nomadhacker.com/uncategorized/creating-a-php-collection-class/comment-page-1/#comment-1319 i need to create a collection class with students,(add/delete,etc) but it must be using the "collection class" concept. It looks like you found it. What's the problem? Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108784 Share on other sites More sharing options...
action Posted September 8, 2010 Author Share Posted September 8, 2010 i dont know where what goes where...and im wondering if anyone has a more basic example cause that one is a bit complicated,atleast for me Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108786 Share on other sites More sharing options...
shlumph Posted September 8, 2010 Share Posted September 8, 2010 You'll probably want your collection implement Iterator and Countable. (http://us3.php.net/Countable) (http://us3.php.net/manual/en/class.iterator.php) However, there's more than one way to skin a cat. There's all sorts of different types of collections you could implement: stacks, queues, linked lists, trees, etc.. I use collections on my blog, here's an example: The abstract class, which implements Iterator and Countable: http://github.com/rkeplin/Blog/blob/master/library/Keplin/Model/Collection/Abstract.php A class which extends the above class: http://github.com/rkeplin/Blog/blob/master/application/models/CategoryCollection.php The class which acts as items in the above collection: http://github.com/rkeplin/Blog/blob/master/application/models/Category.php Hope this helps. Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108794 Share on other sites More sharing options...
action Posted September 8, 2010 Author Share Posted September 8, 2010 any easier examples?im still learning php... Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108902 Share on other sites More sharing options...
shlumph Posted September 8, 2010 Share Posted September 8, 2010 You can always refer to one of the SPL data structures: http://us3.php.net/manual/en/spl.datastructures.php Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1108903 Share on other sites More sharing options...
action Posted September 9, 2010 Author Share Posted September 9, 2010 it has to be a custom generic collection class and not any of the predefined ones(queue,stack) etc. Link to comment https://forums.phpfreaks.com/topic/212881-collection-classes-help/#findComment-1109107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.