foreach not working (1 post)

  1. alastc
    Posted 8 years ago #

    Hi, I have a strange problem with using a foreach loop for showing tags. The code from the codex works fine on my local copy (with PHP 5.2.1), but on the public site (PHP 5.2.0) kinda mashes the elements together.

    So using this code:

    foreach($posttags as $tag) {
    echo "tag: ";
    echo $tag->name . ', ';

    Would output:
    tag: tag1 tag2 tag3,

    But locally, I would get what I expect:
    tag: tag1, tag: tag2, tag: tag3,

    Any clues on how I can do this differently to get around it? I tried for & while loops, but couldn't get it to iterate through the array.

Topic Closed

This topic has been closed to new replies.

About this Topic