Re: PHP Complex Data Structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Zzapper <david@xxxxxxxxxx>:
> I seem to remember that you access/use PHP data in the same/similar
> way to Perl data and that you can create complex data structures ie
> arrays of arrays, arrays of records etc.
>
> For once Google let me down so can any one point at any doc info.

Did you try building any complex data structures? You could have whipped
out something to test pretty quickly. The quick answer is, 'Yes'. 

The longer answer is: cut-and-past the following into a script and see
what you get:

$cds = array(
    'element1' => array(
        'string1',
        'string2',
        'string3'
    ),
    'element2' => true,
    'element3' => array(
        'subelement1' => array(
            array(1, 2, 3),
            2,
            3
        )
    )
);
var_dump($cds);

You can create any complexity you want using nested arrays. Arrays in
PHP are ordered (also called indexed) unless string keys are used (in
which case they're called associative) -- and you can mix and match
styles as needed.

Additionally, you can use these structures within objects, and define
object properties on the fly.

Read through the manual about variable types if you need more
information -- and don't be afraid to experiment.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux