问题描述
代码:
<?php
$ zct2 = array(Canada,France,Germany,Italy,
" Netherlands"," Spain"," United Kingdom");
$ sra = geoip_country_name_by_name($ _ SERVER [''REMOTE_ADDR''' ]);
foreach($ zct2 as $ c){
if($ c = $ sra){
echo $ c;
}
}
未设置$ c
?>
输出:
United StatesUnited StatesUnited StatesUnited StatesUnited
StatesUnited StatesUnited States
问题:
why我多次得到美国,当$ c永远不等于
美国,$ sra等于,但不是$ c
code:
<?php
$zct2 = array ("Canada", "France", "Germany", "Italy",
"Netherlands", "Spain", "United Kingdom");
$sra = geoip_country_name_by_name($_SERVER[''REMOTE_ADDR'']);
foreach ($zct2 as $c) {
if ($c = $sra) {
echo $c;
}
}
unset $c
?>
output:
United StatesUnited StatesUnited StatesUnited StatesUnited
StatesUnited StatesUnited States
question:
why do I get United States that many times, when $c never equivals
UnitedStates at all, $sra is equval that, but not $c
推荐答案
这篇关于foreach quesiton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!