Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-2008, 10:35 AM
gogles gogles is offline
Newbie
 
Join Date: May 2008
Posts: 4
Rep Power: 0
gogles is on a distinguished road
Default array_unique and my duplicates

I have a problem with the array_unique function.

Without the array_unique function the results are:


jessica alba and natalya are friends. 2008-05-13
jessica alba and lars ulrich are friends. 2008-05-13
jessica alba and natalya are friends. 2008-05-13
jessica alba and lars ulrich are friends. 2008-05-13

And with the array_unique function:

jessica alba and natalya are friends. 2008-05-13

The desired result would be.

jessica alba and natalya are friends. 2008-05-13
jessica alba and lars ulrich are friends. 2008-05-13

Any ideas on how i could achieve this result?


PHP Code:
$actions = array();
  
  while (
$row mysql_fetch_array($result_1)) {    
    
$actions[] = array("name" => $row["m_name"],
                       
"name2" => $row["m2_name"],                               
                         
"date" => $row["epoch"]);
  }
  
  while (
$row mysql_fetch_array($result_2)) {
    
$actions[] = array("name" => $row["m_name"],
                       
"name2" => $row["m2_name"],                                   
                         
"date" => $row["epoch"]);
  }
  while (
$row mysql_fetch_array($result_3)) {
    
$actions[] = array("name" => $row["m_name"],
                       
"name2" => $row["m2_name"],                                   
                         
"date" => $row["epoch"]);
  }
  while (
$row mysql_fetch_array($result_4)) {
    
$actions[] = array("name" => $row["m_name"],
                       
"name2" => $row["m2_name"],                                   
                         
"date" => $row["epoch"]);
  }
 
  
$actions array_unique($actions); 

Last edited by Jaan; 05-14-2008 at 02:04 PM. Reason: When you're posting your codes.. use tags!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-13-2008, 11:53 AM
gogles gogles is offline
Newbie
 
Join Date: May 2008
Posts: 4
Rep Power: 0
gogles is on a distinguished road
Default Re: array_unique and my duplicates

This seems to have worked...

PHP Code:
function multi_unique($array) {
    foreach (
$array as $k=>$na)
        
$new[$k] = serialize($na);
    
$uniq array_unique($new);
    foreach(
$uniq as $k=>$ser)
        
$new1[$k] = unserialize($ser);
    return (
$new1);


Last edited by Jaan; 05-14-2008 at 02:05 PM. Reason: When you're posting your codes.. use tags!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 02:09 AM.

Contest Stats

dargueta ........ 128.00000
John ........ 127.00000
Xav ........ 107.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

Ads