I have a string that I receive from another system that looks like this:

<!-- count=2-->
<!-- NAME=value,NAME=value,NAME=value-->
<!-- NAME=value,NAME=value,NAME=value-->

What I would like to do is create a mulitdimensional array with each comment block being a row and the name value pairs for the inner part of the array. I seem to be stuck though. I can parse the name value pairs into one giant array using a regular expression (preg_split to be exact) but since I don't know how many name value pairs will be in the comment blocks, I don't know how to iterate through the big singular array. Does anyone have any idea how I can create a multidimensional array from this type of data or does anyone have a way to make a multidimensional array from one very large single-dimensional array? Thanks.

    explode on line break then loop through that

      Thanks for the help. I split on the '-->' instead. I did this just in case there were line breaks in any return values. Thanks again for the help. That one was bugging me for a while. :-)

        Write a Reply...