Jump to content


Array


2 replies to this topic

#1 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 08 July 2006 - 08:20 PM

Ok well I made an array like

$arr = array(
  "BLAH"  => array('one field', 'two field'),
  "Blah 2" => array('another one', 'again'));

Ok, so is there a way to use in_array to determine if one field is there or not?

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 08 July 2006 - 09:20 PM

Well, I would think it would work just the same as a normal array.
Did you check the PHP Manual?
I think this example has something that might help you.

<?php
$a = array(array('p', 'h'), array('p', 'r'), 'o');

if (in_array(array('p', 'h'), $a)) {
   echo "'ph' was found\n";
}

if (in_array(array('f', 'i'), $a)) {
   echo "'fi' was found\n";
}

if (in_array('o', $a)) {
   echo "'o' was found\n";
}
?>


#3 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 08 July 2006 - 09:49 PM

Thanks mate, I read the manual but didnt see that example :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users