Results 1 to 2 of 2

Thread: Displaying an array

  1. #1
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default Displaying an array

    I'm working on a weblog, and currently, more specifically, the archives. I have an array for the posts for each year, and I want to easily get them on the archives page. Here's an example array, for 2006:

    PHP Code:
    $posts_2006 = array ( => 
    "<li><a href=\"view.php?page=april102006\">April 10, 2006</a> - AIM screen name dilemma.</li>\n",
    "<li><a href=\"view.php?page=january32006\">January 3, 2006</a> - Flickr photography site.</li>\n"); 
    Can I just echo $posts_2006, and the whole array will show up as code, like so:

    <li><a href="view.php....
    <li><a href="view.php...

    etc?

    Or do I have to echo each individual thing, as so:

    $posts_2006[1]
    $posts_2006[2]

    ...etc?

    Help!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    echo(implode('', $posts_2006));
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •