implode() function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DJ Craig

    #1

    implode() function

    I have 2-dimensional array with numeric indices for both dimensions,
    called $results, which contains the search results from a database.
    The first dimension contains the records, and the second contains the
    fields. I want to convert it into an XHTML table to echo to the
    browser. For a 1-dimensional array, I would do this with implode().
    Can I use implode() on a 2D array? If not, is there some other
    function I could use to do this, or will I have to write my own? Or
    has anyone already written one?

  • DJ Craig

    #2
    Re: implode() function

    anybody?

    Comment

    • Wayne

      #3
      Re: implode() function

      On 28 Feb 2005 19:32:25 -0800, "DJ Craig" <spit@djtriciti es.com>
      wrote:
      [color=blue]
      >I have 2-dimensional array with numeric indices for both dimensions,
      >called $results, which contains the search results from a database.
      >The first dimension contains the records, and the second contains the
      >fields. I want to convert it into an XHTML table to echo to the
      >browser. For a 1-dimensional array, I would do this with implode().
      >Can I use implode() on a 2D array?[/color]

      I'm honestly surprised you would use implode() to render a
      1-dimensional array in XHTML. That's a rather hackish approach to the
      problem.
      [color=blue]
      >If not, is there some other
      >function I could use to do this, or will I have to write my own?[/color]

      You'll have to write your own, but the problem is pretty trivial.
      Just iterate both dimensions of the array and print out what you need.

      Comment

      Working...