Output a multi select with selected values from an array?
<p>I have an array of jobs:</p>

<pre><code>$jobs = ['j1', 'j2', 'j3', 'j4', 'j5'];
</code></pre>

<p>I also have an array of user jobs:</p>

<pre><code>$userJobs = ['j1', 'j3'];
</code></pre>

<p>I'm outputting a multi select of all the jobs and I wish to have user jobs selected.</p>

<p>If a user only had one job i would do something like this:</p>

<pre><code>foreach($jobs as $job){
    echo '&lt;option '.$job == $userJob ? 'selected' : ''.'&gt;'.$job.'&lt;/option&gt;';
}
</code></pre>

<p>But how to approach this comparing array without lots of loops?</p>