如何在php数组中存储从查询中检索到的值

i have retrieved a query and tried to store the id column in a array. and then i check two arrays to find the common using array_intersect func....

<?php

    $a=array(10);
    $connection = mysql_connect("localhost","root","");
    $db=mysql_select_db("data",$connection);
    $res=mysql_query("select * from usertable");
    $i=0;
    while($row=mysql_fetch_array($res))
    {
    $a[i]=$row["id"];
    $i++;
    }
    echo $a[1];
    $fb_usr_id =json_decode(  $_POST['fb_user'], true );
    $arr=array($fb_usr_id);


    $result = array_intersect($arr, $a);
    print_r($result);
    ?>

is the way in which i stored the retrieved value in array is correct...?? and output of this code is:

Array ( )

I would do it this way

<?php

    $a;
    $connection = mysql_connect("localhost","root","");
    $db=mysql_select_db("data",$connection);
    $res=mysql_query("select id from usertable");
    $i=0;
    while($row=mysql_fetch_array($res))
    {
    $a[]=$row["id"];    
    }
    echo $a[1];
    $fb_usr_id =json_decode(  $_POST['fb_user'], true );
    $arr=array($fb_usr_id);


    $result = array_intersect($arr, $a);
    print_r($result);
    ?>

It is perfectly fine the way you did it.

Your result just means that there was no connection between the 2 arrays.

I am not sure why you did $arr=array($fb_usr_id); you put an array inside of an array?

Remove that line should get you a correct result.

Right now you are comparing array(array(...)) to array(...) which will never intersect