Filtering through an array for duplicates...lil help
Posted: Fri Jul 03, 2009 10:07 pm
Hello all. I've got a question hopefully I can get a lil help on. Im sort of a PHP novice
Background:
I've created an app in flex that utilizes ZendAMF to make php calls to a db to pull information. the php queries the info it puts all the fields from each record into an object that then gets put into an array thats returned to flex which is then displayed in a datagrid. which Ive been able to get to work fine. 2 of the fields in each record are an agent name and a numerical amount.
Question:
there is a good chance that the agent name will appear more than once as a name variable in each object in the array but the numerical amount which is a price variable in the object could differ from object to object. What i want to do if possible is filter the array and throw out the duplicate object->name object but before disposing of them add all of the price variables of that particular agent, putting it into a total variable of the object and then returning that object so that flex will display in the data grid the agent name once but the total numerical number.
please let me know if this is possible of if this question isnt concise enough and there are questions on my question heh. Thanks to anyone that helps.
Background:
I've created an app in flex that utilizes ZendAMF to make php calls to a db to pull information. the php queries the info it puts all the fields from each record into an object that then gets put into an array thats returned to flex which is then displayed in a datagrid. which Ive been able to get to work fine. 2 of the fields in each record are an agent name and a numerical amount.
Question:
there is a good chance that the agent name will appear more than once as a name variable in each object in the array but the numerical amount which is a price variable in the object could differ from object to object. What i want to do if possible is filter the array and throw out the duplicate object->name object but before disposing of them add all of the price variables of that particular agent, putting it into a total variable of the object and then returning that object so that flex will display in the data grid the agent name once but the total numerical number.
please let me know if this is possible of if this question isnt concise enough and there are questions on my question heh. Thanks to anyone that helps.