I am looking to exclude a specific value from my foreach output where it occurs in either friend_one or friend_two. I do not want to exclude this from my query.
The parameter to exclude would be $profile_user where it occurs in either friend_one or friend_two. I tried to do this if(in_array($friend_total_row->friend_one == $profile_user)), but I am getting errors with it, plus it only has friend_one in it.
Anyone have an idea how I can do this?
<?php
//Friends --- total
$friend_status = 2;
$friend_sql = "
SELECT *
FROM friends
WHERE (friend_one = :profile_user or friend_two = :profile_user)
AND status = :total_status
";
$friend_stmt = $con->prepare($friend_sql);
$friend_stmt->execute(array(':profile_user' => $profile_user, ':total_status' => $friend_status));
$friend_total_rows = $friend_stmt->fetchAll(PDO::FETCH_ASSOC);
$count_total_friend = $friend_stmt->rowCount();
?>
<div id="friend-list-container">
<div id="friend-list-count">Friends <span class="light-gray"><?php echo $count_total_friend; ?></span></div>
<div id="friend-list-image-container">
<?php
foreach ($friend_total_rows as $friend_total_row) {
if(in_array($friend_total_row->friend_one == $profile_user)) {
continue;
}
else {
$friend_1 = $friend_total_row['friend_one'];
$friend_2 = $friend_total_row['friend_two'];
//$friend_status = $friend_total_row['status'];
//$friend_status_date = $friend_total_row['date'];
}
echo $friend_1 . $friend_2;
}
?>
I am only wanting to exclude the $profile_user from outputting, which is where the X is. Then I want the squared output to show.

if(in_array($friend_total_row->friend_one == $profile_user))is wrong. you have to separate by comma, not two equal signs. php.net/manual/en/function.in-array.php