我正在建設使用codeigniter的在線商店,它是購物車庫。我有這樣的陣列插入多維數組codeigniter購物車
$data = Array
(
Array
(
[id] => BM101
[qty] => 1
[price] => 95
[name] => Legal Structures & Tax Accounting
[options] => Array
(
[course_hours] => 4
[course_description] => This course will review the alternative legal forms that may be used to conduct a building/construction business, including proprietorship, partnerships, joint ventures, limited partnerships, C corporations and S corporations. The pros and cons of each type of entity will be examined in terms of personal liability exposure. The income tax and social security tax consequences of each type of entity, as well as the impact on fringe benefit and retirement programs, will be explored.
[class_date] => 2014-03-05
[class_time] => 1:00 p.m. - 4:30 p.m.
[class_instructor] => Richard Allison
)
)
Array
(
[id] => BM102
[qty] => 1
[price] => 95
[name] => Risk Management for Residential General Contractors
[options] => Array
(
[course_hours] => 4
[course_description] => This course will provide a risk management approach to the most common property and liability exposures facing the residential general contractor. A broad review of the major coverage’s builders must have to protect their businesses will be covered. Those coverage’s include: general liability, workers compensation, builders risk, and auto. Other items discussed will be include: contractor tools, office contents, and bonds. This will be a practical approach on how to assess these risks and how to insure them or pass them along to others.
[class_date] => 2014-04-03
[class_time] => 8:30 a.m. - 12:00 p.m.
[class_instructor] => Erik Anderson
)
)
)
當我插入使用$這個 - > cart->插入($數據)只有最後一個項目插入到購物車。如何將多維數組插入到購物車? 我也做循環
foreach ($data as $item){
$this->cart->insert($item);
}
也只能插入的最後一個項目。
foreach循環也許 – 2014-01-20 02:16:47
我已經嘗試使用foreach,因爲我上面提到,但只有第二項數組插入到購物車。爲什麼? –