douyan8070 2014-04-16 11:06
浏览 10

检查返回false的数组值?

I need to check that 2 values from 2 different arrays are the same. I am currently getting one value from mysql and the other from facebook api.

$UserHomeTown[1] is the users location and $city_Value[1] is the friends location but when i try and check the value between these i always get false.

Tested the statement by echoing out to screen and this is what i get

 if (Lancashire === United Kingdom) False 
 if (Lancashire === Lancashire) False

I have tried !=, !==, ===, == and still all i get is false,

Here is my code getting the information from facebook

$userFriend_profile = $facebook->api('/me/friends?fields=name,location');

$total = count($userFriend_profile['data']);
for ($i = 0; $i < $total;)
{
    if(isset($userFriend_profile['data'][$i]['location']['name']))
    {
        $city_Value = explode(',',trim($userFriend_profile['data'][$i]['location']['name']));
        if ($city_Value[0] != $UserHomeTown[0]) { // This on works
        if (isset($city_Value[1])) {
            echo "if ($UserHomeTown[1] === $city_Value[1])";
            if ($UserHomeTown[1] === $city_Value[1]){
                echo "<br> True<br><br>";
            } else {
                echo "<br> False<br><br>";
            }
        }
    }
}
    $i = $i + 1;
}
  • 写回答

2条回答 默认 最新

  • doushi1957 2014-04-16 11:33
    关注

    Though I do not see anything wrong in the code, Try

    if ($UserHomeTown[1] == $city_Value[1]) instead of if ($UserHomeTown[1] === $city_Value[1])

    评论

报告相同问题?

悬赏问题

  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM