[PHP] Please help me with in_array

2006-08-04 Thread Chris G

Hi all

I have been stuck on this problem for 4 hours. Please anyone that can help
here I would appreciate it.

If I print_r($_GET) I have

Array ([question] = Array ( [10] = 1 [11] = 2 [12] = 1 [13] = 1)'


So now I try

foreach($_GET['question'] as $key) {
 if(!in_array($key, $_SESSION['question'])) {
  print not matched lets updatebr.
$_GET[question][$key]; // HERE I WANT IT TO SHOW $key
is 10 and its value should be 1 (as printed in the Array above)
 }
else {
 print matched;
 }
}



Where it gets to the section not matched I need to print out from the
question array question[$key][$value] (question '10' = '1' as above)



I am not sure if I am even making sense here anymore...

Thanks in advance


Chris


Re: [PHP] Please help me with in_array

2006-08-04 Thread Jochem Maas
Chris G wrote:
 Hi all
 
 I have been stuck on this problem for 4 hours. Please anyone that can help
 here I would appreciate it.
 
 If I print_r($_GET) I have
 
 Array ([question] = Array ( [10] = 1 [11] = 2 [12] = 1 [13] = 1)'
 
 
 So now I try
 
 foreach($_GET['question'] as $key) {

foreach($_GET['question'] as $key = $value) {

  if(!in_array($key, $_SESSION['question'])) {
   print not matched lets updatebr.
 $_GET[question][$key]; // HERE I WANT IT TO SHOW $key
 is 10 and its value should be 1 (as printed in the Array above)
  }
 else {
  print matched;
  }
 }
 
 
 
 Where it gets to the section not matched I need to print out from the
 question array question[$key][$value] (question '10' = '1' as above)
 
 
 
 I am not sure if I am even making sense here anymore...
 
 Thanks in advance
 
 
 Chris
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Please help me with in_array

2006-08-04 Thread Jochem Maas
Chris G wrote:
 I have already tried using
  
 foreach($_GET['question'] as $key = $value)
  
 the in_array function does not work with it for some reason.

'does not work with it' ??

use var_dump(); to see what's actually in your variables.

 
  
 On 8/5/06, *Jochem Maas* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 

 foreach($_GET['question'] as $key = $value) {
 

var_dump($key, $value);

   if(!in_array($key, $_SESSION['question'])) {
print not matched lets updatebr.
  $_GET[question][$key]; // HERE I WANT IT TO
 SHOW $key
  is 10 and its value should be 1 (as printed in the Array above)
   }
  else {
   print matched;
   }
  }
 
 
 
  Where it gets to the section not matched I need to print out
 from the
  question array question[$key][$value] (question '10' = '1' as above)
 
 
 
  I am not sure if I am even making sense here anymore...
 
  Thanks in advance
 
 
  Chris
 
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php