Php in_array() not working as expected
<p>I am currently working on a multiple select drop-down list. I need to display the selected values on an edit form.</p>

<p><code>in_array()</code> is not working as I expect, do I have an error in my logic?</p>

<p>The code to display the selected values from the database is:</p>

<pre><code>&lt;div class="form-group"&gt;
    &lt;label class="col-md-3 control-label" for="selectbasic"&gt;Update Artist Selection&lt;/label&gt;
    &lt;div class="col-md-6"&gt;
        &lt;select id="artists1" multiple="multiple" name="id_artist_fk[]" class="form-control "&gt;
            &lt;?php
            foreach ($artist_list as $key =&gt; $value) {
                if (in_array($value['id_artist'], $current_artist_list, true)) {
                    $selected = "selected='selected'";
                }
                // print_r($value['id_artist']. "==". $current_artist_list);
                echo "&lt;option value=\"{$value['id_artist']}\" {$selected}&gt;{$value['name']} {$value['surname']}&lt;/option&gt;";
            }
            ?&gt;
        &lt;/select&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>The <code>$artist_list</code> is gotten via:</p>

<pre><code>public function get_artist_list() {
    $sql = "SELECT * FROM tbl_v_artist WHERE status != 0;";
    $result = $this-&gt;database-&gt;doSelectQuery($sql);
    $artists = array();
    if ($result-&gt;num_rows &gt; 0) {
        while ($row = $result-&gt;fetch_array()) {
            $artist = array(
                'id_artist' =&gt; $row['id_artist'],
                'name' =&gt; $row['name'],
                'surname' =&gt; $row['surname'],
                'status' =&gt; $row['status']
            );
            array_push($artists, $artist);
        }
    }
    return $artists;
}
</code></pre>

<p>The <code>$current_artist_list</code> is gotten via:</p>

<pre><code>$current_artist_list = $vid-&gt;get_artistsID_for_video($_POST['id_video']);
</code></pre>

<p><code>get_artistsID_for_video</code> is:</p>

<pre><code>public function get_artistsID_for_video($video_id) {
    try {
        $sql = "SELECT
                tbl_video_artist.id_artist_fk
                FROM tbl_video_artist
                left join tbl_v_artist
                ON tbl_v_artist.id_artist = tbl_video_artist.id_artists
                WHERE tbl_video_artist.id_video_fk = {$video_id};";
        //echo $sql;
        $result = $this-&gt;database-&gt;doSelectQuery($sql);
        $artists = array();
        if ($result-&gt;num_rows &gt; 0) {
            while ($row = $result-&gt;fetch_array()) {
                $artist = array(
                    'id_artist_fk' =&gt; $row['id_artist_fk']
                );
                array_push($artists, $artist);
            }
        }
        return $artists;
    } catch (Exception $ex) {
        $ex-&gt;getMessage();
        $ex-&gt;getFile();
    }
}
</code></pre>

<p>Please help point me in the right direction.</p>

<hr>

<p>I have edited the get_artistsID_for_video as follows:</p>

<pre><code>public function get_artistsID_for_video($video_id) {
    try {
        $sql = "SELECT
                tbl_video_artist.id_artist_fk
                FROM tbl_video_artist
                left join tbl_v_artist
                ON tbl_v_artist.id_artist = tbl_video_artist.id_artists
                WHERE tbl_video_artist.id_video_fk = {$video_id};";
        //echo $sql;
        $result = $this-&gt;database-&gt;doSelectQuery($sql);
       // $artists = array();
        if ($result-&gt;num_rows &gt; 0) {
            while ($row = $result-&gt;fetch_array()) {
                $artist [] = $row['id_artist_fk'];
               // array_push($artists, $artist);
            }
             return $artist;
        }

    } catch (Exception $ex) {
        $ex-&gt;getMessage();
        $ex-&gt;getFile();
    }
}
</code></pre>