Hi, I would like to achieve something similar as a multidimensional array object in php. As I am a beginner in php I am a bit confused and not sure about the right decision. Is it possible to create an array list in php?Say I have a class class Data { $_name; $_value; //property like functions function getName() { return $_name; } function getValue() {//same code} function Data($name,$value) { $_name = $name; $_value = $value; } } class DataList { $_arrayList = array(); //the parameter I want to pass is a Data class type object function Add($dData) { return array_push($_arrayList, $dData); } } This way I would like to create the list which will contain pairs of name-value and also want to access these pairs from the list when in need, ie: //the parameter is a DataList function getData($dlDataList) { $Data; $name; $Data = $dlDataList[0]; $name = $dlDataList[0]->getName(); } Is it possible to do something similar in php? Thanks for any help/clarification Ben
Actually there are multydimensional arrays in PHP - $arr[0][3][2]. There are also associative arrays - $color['cat'] = "black". And combied $arr['cat']['color'] = "black"; $arr['cat']['legs'] = 4; You can even use variables as array indexes $arr[$pet] for example. Or maybe I just did not understand your question.
What I want to achieve is, instead of array members like name, value I want to pass a MyData type, which actually is a pair of name, value variables, into the array list.So it will be not an array of string variables, but an array of MyData types.And backwards to access these MyData members of the array list. Thanks Ben