PHP爆阵帮助 [英] php imploding array help
本文介绍了PHP爆阵帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给破灭了用户ID的$ users_in_range阵列的问题是,它是iploding英里,而不是用户ID在
< PHP
$ users_in_range = users_in_range($经纬度,$长,500,真正的);//爆用户到mysql友好名单
$ comma_separated =破灭(,,$ users_in_range);
回声$ comma_separated;//这只是输出,同时调试
的foreach($ users_in_range为$用户id => $ miles_away){
回声用户名=< B> $用户用户名与LT; / B>为< B> $ miles_away< / B>从我英里远< BR />中;
}
?>
解决方案
该用户ID为阵列的关键,所以你需要做的:
$ comma_separated =破灭(,array_keys($ users_in_range));
I am trying to the implode the userIDs in the $users_in_range array the problem is it is iploding miles instead of userid
<?PHP
$users_in_range = users_in_range($lat, $long, 500, true);
// implode users into mysql friendly list
$comma_separated = implode(",", $users_in_range);
echo $comma_separated;
// this is just for output while debugging
foreach ($users_in_range as $userid => $miles_away) {
echo "UserID=<b>$userid</b> is <b>$miles_away</b> miles away from me.<br />";
}
?>
解决方案
The userid is the key of the array, so you need to do:
$comma_separated = implode(",", array_keys($users_in_range));
这篇关于PHP爆阵帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文