um... what technique? array_merge or array_merge_recursive is the function to do what you want...

    waahh!!..its harddd!!!..it is ok if my arrays are not that complicated..it seems that i have multidimensional associative array combine with index array...ahahhahaaa..that's why it is hard for me to find any example..all the example always give me problemss..

    after studying the functions u told me to study...
    i come out with new array stucture..

    $y_res[$i] = array( $y_URL[$i] => array ($y_arr[$i], 'Yahoo'));
    $a_res[$i] = array( $a_URL[$i] => array ($a_array[$i], 'Altavista'));

    i believe i have index array '$y_res[1]..[10]' if i'm not mistaken..and associative array 'array( $y_URL[$i] => array ($y_arr[$i], 'Yahoo'));' and multidimensional array.. 'array ($y_arr[$i], 'Yahoo'));'..

    normally for the associative we have.. this kind
    <?php
    $ar1 = array("color" => array("favorite" => "red"), 5);
    $ar2 = array(10, "color" => array("favorite" => "green", "blue"));
    $result = array_merge_recursive($ar1, $ar2);
    ?>

    but unfortunately i have this kind..
    $y_res[$i] = array( $y_URL[$i] => array ($y_arr[$i], 'Yahoo'));

    e.g: $y_res[1] <-- result 1
    $y_res[2] <--- result 2
    each have own..url( $y_URL[$i] ) and desc ($y_arr[$i])...

    I'M SOOO IN DILEMMMAAAA!!
    uuwaa~~

    its hard to filter for same URL..for both arrays...

      say what? You can have as many multi-dimensional arrays as you want. As long as they're all structured the same, you can merge them....

        its not merging i want exactly..i want to filter if any same URL between two arrays..
        my key to compare here is URL.. so if URL from $a_URL[$i] same to $y_URL[$i] the $a_URL[$i] will be deleted but for the $y_res[$i] array the infor from'Altavista' will be added into it...gegegeee~~..i'm sooo sory for this difficult..

          is there anybody can help me with this??..huhuhhuu~~

            Then you'd have to write your own function that goes in and reads each of the arrays. If the array items are the same then it does what you say, and moves on... To make it recursive, you'd have to call the function again from within the function...

              You have two arrays. You want to merge the arrays such that the resulting array contains entries that are unique, where uniqueness is a user defined property. Is that it?

                yes..it is..i want to eliminate the redundant element between two arrays

                i've wrote some coding that prove not to be working...i'm once again stuck..

                //FILTERING PROCESSES
                $j = count($a_res);
                for ($i=1; $i<count($y_res); $i++)
                {
                foreach($y_res[$i] as $yres => $yurl)
                {
                while($j>0){
                foreach($a_res[$j] as $ares => $aurl)
                {
                if ($ares == $yres)
                echo $url[0];
                else
                $y_res[$i+1] = $a_res[$j];// = array( $a_URL[$j] => array ($a_array[$i], 'Altavista'));;
                }
                $j=$j-1;
                }
                }
                }

                you all might say that this coding is stupid..but that's all i can think off..i'm a newbie afterall..hehehee

                  the pseudocode..

                  this will compare each URL of results from yahoo and altavista
                  yahoo[1..10]
                  altavista[1..0]

                  foreach altavista result[1..10]
                  compare alta_url to each of yahoo_url[1..10]
                  (one alta_url compare to all 10..then loop again for another alta_url)
                  if same URL the DELETE alta_result element for that index e.g. (a_res[1])
                  but then in yahoo_result need to ADD info from 'Altavista' after 'Yahoo' so that result like follows:
                  $y_res[$i] = array( $y_URL[$i] => array ($y_arr[$i], 'Yahoo', 'Altavista'));
                  if not same..recursive or call the function again...

                  (the Yahoo results will remain 10 if no same URL or added up if same URL exist)
                  (the altavista results will be deleted if sama URL and remain 10 if no same URL)

                  huhuuu~~...

                  right now i am trying the array_merge_recursive function and i do some editting to the coding for the comparison, adding and eliminating the elements..but yet to be solved..

                  any idea for this...???

                    Why do 2 loops? Use the already available search functions:

                    Loop through 1 array. While in that loop, do an [man]array_search/man on the other array for the current value of the first array.

                    Then, if you've got 10 links, you do 10 loops, 10 searches, and your code would be slightly faster.

                      i thought tht's what i'm trying to say from the beginning..but obviously i'm not good at describing the prob..hehheee..

                      well..i guess its not easy to ask question virtually right..even my lecturer couldnt understand what i'm trying to say..hehe..

                      but then again the reason i seek help from this forum is to know how do i code..i understand wht u r trying to say bcoz that's wht i meant...but could u juz show me a bit how the coding looks like..bcoz whtever version i did wouldnt do...if that's possible..

                      but i'm still trying right now..

                        Well, aight, since it took so long to get it out and clarified:

                        // Assuming $y_arr and $a_arr are populated . . .
                        
                        foreach($y_res as $res=>$url)
                        {
                          if(FALSE != ($key = array_search($url, $a_arr)))
                          {
                            array_push($y_arr[$res], $url);
                            $a_arr = removeElement($url, $a_arr);
                          }
                        }
                        
                        function removeElement($item, $array)
                        {
                        	$key = array_search($item, $array);
                        	if($key>0 && $key<(count($array)-1)) // Not first or last item
                        	{
                        		// A fairly simple process of removing the middle element
                        		if((int)substr(phpversion(), 0, 1) >= 5)
                        		{
                        			$arr1 = array_slice($array, 0, ($key));
                        			$arr2 = array_slice($array, $key+1);
                        			$new_array = array_merge($arr1, $arr2);
                        		}
                        		elseif((int)substr(phpversion(), 0, 1) == 4)
                        		{
                        			$arr1 = $arr2 = $array;
                        			array_splice($arr1, 0, ($key+1));
                        			array_splice($arr2, $key);
                        			$new_array = array_merge($arr2, $arr1);
                        		}
                        		else
                        		{
                        			// PHP version less than 4 ewww....
                        			$array[$key] == '';
                        			$new_array = $array;
                        		}
                        	}
                        	elseif($key===0)
                        	{
                        		// Remove the first element
                        		array_shift($array);
                        		$new_array = $array;
                        	}
                        	elseif($key==(count($array)-1))
                        	{
                        		// Remove the last element
                        		array_pop($array);
                        		$new_array = $array;
                        	}
                        	else
                        	{
                        		// Not found, return usual array (in case of hacking or mess-ups)
                        		$new_array = $array;
                        	}
                        	// Send the array back
                        	return $new_array;
                        }

                        SOmething like that

                          waahh..thank you..i feel like jumping already for feeling sooo happy eventhough i havent test the coding yet..hehehee..i am absolutely gonna test them right now..

                          thank you!!
                          thank you!!
                          thank you!!

                          -suddenly becoming energetic..-

                          i'll come back later after testing.. ;-)

                            bpat1434's example has a bug though, and it is up to you to fix it.

                            Hint: array_search() returns false if the search value is not found. What does (false == 0) evaluate to?

                            Once you figure out the fix, you can eliminate one of the (count($array)-1) expressions.
                            Also, if you are using PHP5, you may find using [man]array_slice/man with preserve_keys better than using array_splice().

                              owh..i am using php 4.3.3

                              guguu~~..i am beginning to feel like drowning in the quicksand..these FYP of mine is becoming more and more difficult to solve each days..

                              still trying to do some editting though~~..

                              thank you guys for helping me~~..anybody else wanna give some ideas..you are soooo welcomed...

                              pity me - helplesss Final Year student-

                                Hint: array_search() returns false if the search value is not found. What does (false == 0) evaluate to?

                                I'm not seeing it.. could you please explain?

                                EDIT
                                I'm guessing:
                                False == 0, so if $key == FALSE then the elseif($key==0) will fire right?

                                Perhaps it should be:
                                elseif($key===0)
                                to make sure that it's an integer returned.... not a bool or integer...

                                Yeah.. that was it... THanks for that Laser.... good eyes

                                But I'm still not seeing how i can reduce the count() calls... or are you just saying that there's no other option once it's past the other two....

                                [EDIT]
                                I updated the code for PHP 5 using array_slice, PHP4 using array_splice, and PHP3 using the normal $array[$key] = '' methods. Even though PHP4/5 support both array_s(p)lice....

                                  But I'm still not seeing how i can reduce the count() calls... or are you just saying that there's no other option once it's past the other two....

                                  For example:

                                  function removeElement($item, $array)
                                  {
                                  	if (($key = array_search($item, $array)) !== false)
                                  	{
                                  		if ($key == 0)
                                  		{
                                  			// Remove the first element
                                  			array_shift($array);
                                  		}
                                  		elseif ($key < (count($array)-1)) // Not first or last item
                                  		{
                                  			// A fairly simple process of removing the middle element
                                  			$arr1 = $arr2 = $array;
                                  			array_splice($arr1, 0, ($key+1));
                                  			array_splice($arr2, $key);
                                  			$array = array_merge($arr1, $arr2);
                                  		}
                                  		else
                                  		{
                                  			// Remove the last element
                                  			array_pop($array);
                                  		}
                                  	}
                                  	return $array;
                                  }

                                    Very true... I see it now. Thanks!!

                                      i am amazed by you guyz..are u all pro or wht..well i guess u all should be..i was like struggling to understand the coding and u all like its nothing~~..

                                      god i am amazed..

                                      btw..i'm not yet fully understand the coding..i really need to understand that first then only i can tell how it works or not with the rest of my coding...i'm dammmn one slow learner..

                                        I just realised - we're dealing with numerically indexed arrays, so there's no reason to use array_splice() where array_slice() will do.

                                        // remove item from array
                                        function removeElement($item, $array)
                                        {
                                        	// find the key of $item in $array
                                        	if (($key = array_search($item, $array)) !== false)
                                        	{
                                        		if ($key == 0) // first element
                                        		{
                                        			array_shift($array);
                                        		}
                                        		elseif ($key < (count($array) - 1)) // not first or last element
                                        		{
                                        			$array = array_merge(
                                        				array_slice($array, 0, $key), // part of array before item
                                        				array_slice($array, $key + 1) // part of array after item
                                        				);
                                        		}
                                        		else // must be last element
                                        		{
                                        			array_pop($array);
                                        		}
                                        	}
                                        	// return the array with the item removed
                                        	// if the item is not found, the array is returned unmodified
                                        	return $array;
                                        }

                                        i am amazed by you guyz..are u all pro or wht..well i guess u all should be..i was like struggling to understand the coding and u all like its nothing~~..

                                        I am a student too (from the island down south), all you need is more practice and experience.
                                        The PHP Manual at php.net is invaluable.

                                        By the way, since this is your FYP, I should say that the algorithm you outlined to compare URLs is potentially very slow (effectively an O(n**2) time algorithm). If the URL lists are in sorted order (e.g. place items in sorted order when creating list), you can merge them with a single pass (think O(n) time) through each list, assuming you create another list to hold the result. Even if you have to sort, sorting should take O(n log n) time, which is still faster than your current algorithm.