8 Replies Latest reply on Jun 20, 2011 7:44 AM by osgood_

    php arrays (match pair)

    osgood_ Level 8

      Is it possible to match php 'arrays'?

       

      $animal = array("rabbit", "dog", "bird", "fox");

       

      $home = array("hutch", "kennel", "nest", "den");

       

      I need to match the pairs above i.e., rabbit-hutch, dog-kennel etc

       

      I get the values from a form see below (but that's where I get lost ??????).

       

      I need the bit which basically says if the 'animal' answer provided by the end user is equal to $animal [0,1,2,3] and the 'home' answer is equal to $home[0,1,2,3]  they get the message 'Correct Answer' if the pair is a match?

       

       

      if (trim($_POST['animal']) == ?????? && trim($_POST['home]) == ??????)
      {
      echo "Correct Answer";
      }
      else {

      echo "Wrong answer";
      {

       

      Cheers

      Os