John C. John C. - 1 year ago 72
JSON Question

PHP IF How to include multiple conditions?

I'm working on a PHP script that reads information from a JSON API, the purpose is to collect the information from the API and put it into a CSV file. I want to exclude certain pieces of information, so far I've only had one exclusion and it worked great but now I'm trying to add a second and can't seem to get it to work correctly. Is this the correct way to join the two conditions together?

$structure_type = $data['sam_data']['registration']['corporateStructureName'];
if($structure_type != "U.S. Government Entity" OR "Non-Profit Organization"){

I'm trying to make this so if either one of those phrases comes up under corporateStructureName then it is excluded. I thought using OR was correct but it doesn't seem to function.

Answer Source

You need to have complete expressions either side of the OR.

if (!($structure_type == "U.S. Government Entity" OR
      $structure_type == "Non-Profit Organization")){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download