开发者

Echo outside of if statement

Here is my code

if ($follower_username == $user){

echo $followed_username.",";

};

When this runs it echos name,name2,name3,name4

however when I did this

if ($follower_username == $user){

$names = $followed_username.",";
};

echo $name`;

it only outputs name4,

What is causing it to only pull the last name?

Than开发者_高级运维ks!


if ($follower_username == $user) {
  $names .= $followed_username;
}
echo $names;


Try this out:

//outside your loop:
$names = '';

while(){
    //...code

   if ($follower_username == $user){

   $names .= $followed_username.",";
   };

   echo $names;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜