Jump to content

[SOLVED] basic syntax help


teknojunkey

Recommended Posts

hi , can anyone advise me on how to get this right, i want to add an if statement.

 

print_r ($_SESSION['submitted'][30]['other'] ); //if this has a value  echo "choice 1";

print_r ($_SESSION['submitted'][31]['other'] ); //if this has a value  echo "choice 2";

 

print_r($session); this is what i get with one form filled in:

[30] => Array ( [other] => )

[31] => Array ( [other] => 70MM )

 

thanks

 

any book / pdf recomendations on php basics?

Link to comment
https://forums.phpfreaks.com/topic/146534-solved-basic-syntax-help/
Share on other sites

if(strlen($_SESSION['submitted'][30]['other'])) {
   echo "choice 1";
}
if(strlen($_SESSION['submitted'][31]['other'])) {
   echo "choice 2";
}

 

If you have many array keys i.e. 30,31,32,33, etc then you may want to run through a loop

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.