Jump to content

multiple comparisons in if statement syntax help


Darkmatter5

Recommended Posts

Can survey_id_1,survey_id_2,survey_id_3 etc can be kept in an array ?

 

As d.shankar suggests, you could do this:

<?php
if (in_array($field, array('survey_id_1', 'survey_id_2', 'survey_id_3'))
{

}
?>

 

In this case, though, that's not much of an improvement on length, unless you can build the comparative array dynamically in your code. Also, using your if clause is probably much faster than trying to use another function call for the comparison.

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.