php - Adding to an array that is a class property, with non-class item -
here simple code not working.
i declare class. class contains empty array. then, outside class try populate single item (another array) in simple way.
class order { public $productarr = array(); function __construct (){ } } $order = new order(); $drummachine = array('category' => 'musical instrument', 'brand' => 'emu', 'model' => 'sp1200'); $order->$productsarr[$drummachine];
what's correct way this? $drummachine come $_session['cart'] i've simplified here.
i've done procedural programming…!
your approach quite off, may want boil basics php , learn general syntax. however, here's you're looking for.
$order->productarr[] = $drummachine;
you're wanting access productarr attribute directly, no $ necessary, , [] = add new item end of array
Comments
Post a Comment