title: How do I use this seemingly simple loop in CodeIgniter's view?
body: <p>In the <strong>view</strong>, right before the footer, I want to load three JavaScript files.  So, the controller sets three variables. For example, $js_1 = "bootstrap.js", $js_2 = '' and $js_3 = "tinymce.js", which may or may not be empty. The logic is, it should echo only if the variable is not empty. I also want to use the <strong>ternary if operator</strong>.</p>
  
  <p>This was the best I could try.</p>
  
  <pre><code>for ($i = 1; $i &lt;= 3; $i++)
  {
      echo (!empty ('$js_' . $i)) ? get_jscript('$js_' . $i) : NULL;
  }
  </code></pre>
  
  <p>The function get_jscript() simply returns the HTML script src.</p>
  
  <pre><code>function get_jscript($js) 
  {
      return '&lt;script type="text/javascript" src="' . $js . '"&gt;&lt;/script&gt; ';
  }
  </code></pre>
  
  <p>Please note that I intend to ask this question to primarily learn the correct PHP syntax and not just load JS in the view.</p>