|
Posted by Jerry Stuckle on 02/07/07 17:52
Aggelos wrote:
>> But one question - you say you have a two dimensional array. But this
>> is only a single dimensional array. It just happens that an array
>> element might itself be an array. That's not two dimensions.
>
> ok I'll explain to you and tell me if I am wrong.
>
> I have class package and class product
>
> A package has many products when I call my constructor for the package
> I create an array of it's products as well.
>
> CODE:
>
> class package {
> var $packageId;
> var $title;
> var $description;
>
> var $_productArray = array();
>
> function package($packageId=NULL,$title=NULL,$description=NULL) {
> $this->packageId = $packageId;
> $this->title = $title;
> $this->description = $description;
>
> $productPackageArray = product_package::select(array('package_id'=>
> $packageId));
> foreach($productPackageArray[$packageId] as $contentId =>
> $publishedArray) {
> foreach($publishedArray as $published => $productValue) {
> $_ObjProduct = product::select(array('content_id'=>
> $contentId,'published'=>$published));
> $this->_productArray[$_product[$contentId][$published]-
>> productTypeId] = $_ObjProduct;
> }
> }
> }
> ......
> }
>
> END OF CODE
>
> I am not sure if you'll understand my code but anyway I end up
> creating product packages and having an object package which instead
> of having just the ids of the products has the whole object in it.
>
> and that creates an array like that $package[$packageId]-
>> _productArray[$productTypeId] = $_ObjProduct; (I don't know how to
> symbolize the object inside the array)
>
> So how many dimensions is that and how does it look to you Jerry. ?
>
>
Aggelos,
This is still a single-dimensional array. Two dimensional arrays are
access by two subscripts, i.e. $myarray[1][2].
And yes, I understand your code. But again - what does the *data* look
like, and what do you expect for output?
Try populating your array and print it with print_r(). Post it along
with what you would like the output to look like.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|