PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 4th, 2013, 11:39 AM
pearl_123 pearl_123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 65 pearl_123 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 58 m 24 sec
Reputation Power: 0
Find duplicate values in multidimentional array

Hi to all,

I have multidimensional array and want find the duplicate values

Code:

array(2) {
  [1]=>
  array(3) {
    [0]=>
    string(19) "2013-02-04 02:48:00"
    [1]=>
    string(19) "2013-02-05 08:48:00"
    [2]=>
    string(19) "2013-02-06 21:48:00"
  }
  [2]=>
  array(9) {
    [0]=>
    string(19) "2013-02-04 01:48:00"
    [1]=>
    string(19) "2013-02-04 02:48:00"
    [2]=>
    string(19) "2013-02-04 22:48:00"
    [3]=>
    string(19) "2013-02-05 05:48:00"
    [4]=>
    string(19) "2013-02-05 08:48:00"
    [5]=>
    string(19) "2013-02-05 22:48:00"
    [6]=>
    string(19) "2013-02-06 02:48:00"
    [7]=>
    string(19) "2013-02-06 08:48:00"
    [8]=>
    string(19) "2013-02-06 22:48:00"
  }
  [4]=>
  array(9) {
    [0]=>
    string(19) "2013-02-04 01:48:00"
    [1]=>
    string(19) "2013-02-04 08:48:00"
    [2]=>
    string(19) "2013-02-04 22:48:00"
    [3]=>
    string(19) "2013-02-05 02:48:00"
  }
}


I have two database table for example table1 and table2

table1 has following fields
Code:
t1_ID   Start_date


table2
Code:
t2_ID   service_id  t1_ID


i want to insert the duplicate start_date once in table1 and then the id of that record in table2

For example in above array

Code:
arr[1][0]
arr[2][1]
arr[4][3]


has same start date which is 2013-02-05 02:48:00 i want to put this in table1 once like

t1_ID start Date

1 2013-02-05 02:48:00


Now in table2

t2_ID service_ID t1_ID
1 1 1
2 2 1
3 4 1

Its mean in table2 subarray which has duplicate values will be inserted against it along the service id which is the index of the array which we are setting .

thanks.

Reply With Quote
  #2  
Old February 4th, 2013, 04:15 PM
volterony volterony is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 60 volterony User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 54 m 32 sec
Reputation Power: 3
Could you not change the table structure to include a third table and create a many to many relationship, so you can see every entry as unique, and then do your filtering from this?

volterony

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Find duplicate values in multidimentional array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap