Re: PHP Complex Data Structures

From: Date: Wed, 18 May 2005 01:28:07 +0000
Subject: Re: PHP Complex Data Structures
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-215427@lists.php.net to get a copy of this message
* Zzapper <david@tvis.co.uk>: > 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@garden.org | http://vermontbotanical.org

« previous php.general (#215427) next »