if/else inside foreach loop problem
-
I’ve set up a foreach loop which works fine, except for some reason a standard if/else statement is not working properly. It seems to be returning true for the same variable on each loop.
if ($results) { echo "<ul>"; foreach ($results as $o): $type = $o->action_type; $post = get_post($o->post_id); $time = $o->action_time; $user = $o->user_id; if ($type = 'lame') { $phrase = 'this was lame'; } else { $phrase = 'something else'; } ?> <div class="floatLeft"><?php user_avatar($user, 50); ?></div> <p><?php echo TimeAgoInWords($time); ?> ago</p> <p><?php user_nickname($user); ?> <?php echo $phrase; ?></p> <?php endforeach; }
Its seems that as long as any value is “lame” it will return true, yet if i just echo out the value without the if/else, it will put the actual value.
Any ideas?
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘if/else inside foreach loop problem’ is closed to new replies.