Results 1 to 3 of 3

Thread: logic question

  1. #1
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default logic question

    hi i have a question regarding some logic.

    well lets say we have 2 arrays.

    arr1 = array('orange','apple','banana','grapes');
    arr2 = array('orange','banana','grapes');

    i want to create a loop to compare these two arrays and to determine the differences between this two arrays. for this case it would be the 'apple' which is the odd 1.

    any help would be appreciated. thanks

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You can try array_search() and array_shift().
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    awakener1986 (01-25-2010)

  4. #3
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default $newarray=array_diff($arr1,$arr2); print_r($newarray);

    $newarray=array_diff($arr1,$arr2);
    print_r($newarray);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •