title: Call if statement inside update post call
body: <p>I'm almost done with a script that I built, but I have one question.</p>
  <p>I have the following function:</p>
  <pre><code>function clean_post_titles() {
      $office_data = get_offices_array();
      foreach ($office_data as $office) {
          if ($office['brand']) {
              wp_update_post([
                  'ID' =&gt; $office['post_id'],
                  'post_title' =&gt; $office['brand'] . ' (' . $office['location'] . ')'
              ]);
          } else {
              wp_update_post([
                  'ID' =&gt; $office['post_id'],
                  'post_title' =&gt; $office['office'] . ' (' . $office['location'] . ')'
              ]);
          }
      }
      echo 'All of the office titles have been updated';
  }
  </code></pre>
  <p>The function works great, but there are instances where <code>$office['location']</code> is missing and I get an output as <code>Office ()</code> instead of <code>Office (Location)</code>.</p>
  <p>Is there a way to call an if statement inside the actual <code>wp_update_post</code>? Like something along the lines of <code>'post_title' =&gt; $office['brand'] . if ($office['location']) ' (' . $office['location'] . ')'</code></p>
  <p><strong>Could I somehow incorporate a ternary operator? - Also, if you think I can clean up the code a bit, please guide me</strong></p>
  <p>If there is brand and no office, just output brand, otherwise combine brand + location with the parentheses.</p>
  <p>All help is appreciated!</p>