I have 2 arrays :
-------------------------------------
$domains = array("strawberries.com","bananas.com","apples.com");
// add selected item to array2
if ($add) { $selected_domains[]=$add; }
-------------------------------------
How can I iterate through array1 and compare each element in array1 to each element in array2 without messing up the list order that is being displayed?
What I have working so far is comparing array1 to the last added element of array2, but I would like to compare array1 to each element of array2 meaning that if a domain has been added that the "delete" link should be displayed and if the domain has not been added the "add" link should be displayed.
I tried several things but I can't get it to work properly.
Check out the in_array() function. You can use that to test if $add is in the array, and if it is go to the delete function, if it isn't add it. I think that'll be easier, if I'm understanding what you have in mind correctly.
Bookmarks