开发者

Echo outside of if statement

开发者 https://www.devze.com 2023-03-02 20:46 出处:网络
Here is my code if ($follower_username == $user){ echo $followed_username.\",\"; }; When this runs it echos name,name2,name3,name4

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

精彩评论

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