PHP array_diff() 函数的问题
这是我的代码...
<?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;
echo " ";
}
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 " ";
}
?>
我正在收到输出,因为
1 5 11 12 13 14 15 16 17 18 19 20
Array
15 16 17 18 19 20
我不知道为什么我会收到像 Array
这样的结果。我想收到不同的值
1 5 11 12 13 14
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;
echo " ";
}
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请尝试以下操作:
Try the following:
array_diff_assoc
返回一个数组,您正在回显该数组。尝试使用print_r()
或var_dump()
而不是 echo 来查看数组的内容。array_diff_assoc
returns an array, which you're echoing out. tryprint_r()
orvar_dump()
instead of echo to view the array's contents.