Jump to content

Referencing two-dimension array records...


Rohlan

Recommended Posts

Hi everyone.

 

I've been trying to figure this out for hours now and I'm feeling like throwing down the towel... though I'm sure I'm very close to finding the way to do it... I've googled a bit but I don't think I know very well what to search about...

 

This is my array (its a big one get ready):

 

Array
(
    [quartos] => Array
        (
            [designacao] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [dimensoes] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [andar] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [janelas] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [pavimentos] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [mobilia] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [obs] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [extras] => Array
                (
                    [0] => in
                    [1] => in
                )

            [id] => Array
                (
                    [0] => 1
                    [1] => 1
                )

        )

    [wcs] => Array
        (
            [designacao] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [dimensoes] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [andar] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [janelas] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [pavimentos] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [mobilia] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [obs] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [extras] => Array
                (
                    [0] => in
                    [1] => in
                )

            [id] => Array
                (
                    [0] => 1
                    [1] => 1
                )

        )

)

 

What I need to do is turn these values into a string. However I can't seem to be able to obtain the values themselves.

 

I know I can simply

 

echo $array[quartos][designacao][0]
echo $array[quartos][designacao][1]
echo $array[quartos][designacao][2]
echo $array[quartos][designacao][3]
.
.
.

 

But I need a loop to iterate through the array and do it without having to do it manually.

 

I just can't seem to find out how to do it...

 

Any ideas?

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/185546-referencing-two-dimension-array-records/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.