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;
}
精彩评论