Search the Community
Showing results for tags 'comparing arrays'.
-
Hello Everyone, I am working on a CMS site and I'm stuck very badly with arrays. I don't have much experience with arrays. In fact, this is probably the first time I have used them this heavily. Here is my situation: I have a for each loop with $i++; which takes values from sessions and puts them into arrays: $bundle_pickup[$i]['bundle_ID']=$bundle_ID; $bundle_pickup[$i]['pickup_date']=$_SESSION['bundle'][$bundle_ID]['pickup_date']; $bundle_pickup[$i]['pickup_time']=$_SESSION['bundle'][$bundle_ID]['pickup_time']; $bundle_pickup prints the following total results: Array ( [1] => Array ( [bundle_ID] => 3 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [2] => Array ( [bundle_ID] => 4 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [3] => Array ( [bundle_ID] => 5 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [4] => Array ( [bundle_ID] => 6 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) ) Everything so far is good. Here is what I need to do: I need to loop through $bundle_pickup array and find out which arrays are different. I need to get $bundle_pickup['bundle_ID'] of all the unique arrays The idea is, if the customer picks same pickup date and time for all bundles, he only pays one pickup charge. If he chooses multiple pickup dates or times, he will need to pay multiple charges. If two bundles have same pickup dates/times and other two have same ( but different than first two ), the customer will pay two pick up charges. Since this is a CMS site, I will not know the bundle_ID, pickup dates, pickup times and order of the bundles. If anyone can suggest how I can get $bundle_pickup['bundle_ID'] of all the unique arrays, that would be greatly appreciated. Once I have the IDs, I can use them to fetch other data from the database. Thanks in advance. Jatt Surma
- 2 replies
-
- php arrays
- multidimensional arrays
- (and 3 more)