Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding duplicate within multiple serialized arrays

Status
Not open for further replies.

webdev007

Programmer
Sep 9, 2005
168
I am not able to come with a logic for merging multiple serialized arrays

Each serialized array contains any num of tags

I need to avoid in result any tag/tags duplicate that could possibly exists in each other array (I do not seek removing dupes)

I think that starting by merging the serialized arrays could be an option and then using twice flip() to avoid listing the dupes?
but I was not successful with the merging process.
How will you perform the task at hand?
your logic?
Thank you
 
This is what I came with but resulting in no real progress
the bottom part is only a test search segment
it looks like using or not using array_merge gives the same (non merged) result
which is:
Array ( [0] => Array ( [0] => dddd [1] => asas ) ) Array ( [0] => Array ( [0] => dddd [1] => ffffff ) ) Array ( [0] => Array ( [0] => asas [1] => asas [2] => asasas ) ) Array ( [0] => Array ( [0] => asasas [1] => dddd [2] => ddddd mmmm ) )

why may not I get a correct result, obviously I am wrong somewhere!
$num_tags=$db->num_rows($result_tags);

////// ajax call:
while ($row=$db->fetch_assoc($result_tags))
{
$tags=$row['tags'];
$i_tags=0;

while($i_tags <$num_tags)
{

$tags=mysql_result($result_tags, $i_tags, "tags");
$tags=unserialize($tags);

$tags=array_merge(array($tags)); print_r($tags);

$search="ddddd mmmm";
foreach($tags as $tags)
{
if(in_array($search, $tags)) { echo'OK'; }
}
$i_tags++;
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top