开发者

Problem on PHP array_diff() function

Here this is my code...

<?php 
include("db.php");
    $team_id=$_GET['team_id'];
    $sql1=mysql_query("select members from team where team_id='$team_id'");
    $sql=mysql_query("select user_id from users where school_id= '1'"); 

    while($array=mysql_fetch_assoc($sql))
        {
            $x[] = $array['user_id'];

        }

    echo "<hr/>";

    foreach($x as $tem){
            echo $tem;
            开发者_如何学Pythonecho "  ";
    }
    echo "</br>";
    $row1=mysql_fetch_array($sql1);
    $member=unserialize($row1['members']);
    echo array_diff_assoc($x ,$member);

    echo "</br>";
        foreach($member as $tem){
                echo $tem;
                echo "  ";
        }
?>

and I'm receiving the output as

1 5 11 12 13 14 15 16 17 18 19 20
Array
15 16 17 18 19 20 

I don't know why im recieving like Array. I want to receive the different values as

1 5 11 12 13 14


Try the following:

foreach(array_diff_assoc($x ,$member) as $item)
{
    echo $item;
}


array_diff_assoc returns an array, which you're echoing out. try print_r() or var_dump() instead of echo to view the array's contents.


print_r(array_diff_assoc($x ,$member));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜