PHP Classes

Problem with array object

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Problem with array object  
Subject:Problem with array object
Summary:Object of class Product could not be converted to string
Messages:3
Author:Darren Whittington
Date:2010-05-19 21:24:49
Update:2010-05-22 21:24:07
 

  1. Problem with array object   Reply   Report abuse  
Picture of Darren Whittington Darren Whittington - 2010-05-19 21:40:27
Hi I have adapted a basket script to take products as objects, when I try to subtract a product from the basket array i get the above error, they look like this:
>>> to remove from basket
Product Object
(
[productId] => 3
[accessories] => Array
(
[0] => fab_prot
[1] => endcap
)

[productQuantity] => 0
)

>>> this is the existing basket
Array
(
[0] => Product Object
(
[productId] => 1
[accessories] => Array
(
)

[productQuantity] => 1
)

[1] => Product Object
(
[productId] => 3
[accessories] => Array
(
[0] => fab_prot
[1] => endcap
)

[productQuantity] => 0
)

)


This is the method/function i'm using:

function DeleteFromBasket($id)
{
echo "<pre>";
print_r($product = $this->getProduct($id)); //outputs the lines above
print_r($this->products);
echo "<pre>";
$this->products = array_diff($this->products, array($product));
return true;
}

Darren

There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.