2014-01-20 3 views
0

나는 codeigniter를 사용하여 온라인 상점을 건축 중이며 그 카트 라이브러리입니다. 나는이 배열을 가지고있다codeigniter cart에 다차원 배열을 삽입하십시오.

$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 
       ) 

     ) 

) 

나는 $ this-> cart-> insert ($ data)를 사용하여 카트에 마지막으로 삽입 된 항목 만 삽입 할 때. 장바구니에 다차원 배열을 삽입하는 방법? 나는 또한 또한 마지막 항목을 삽입

foreach ($data as $item){ 
$this->cart->insert($item); 
} 

반복으로한다.

+0

아마도 foreach 루프 –

+0

위와 같이 foreach를 사용해 보았지만 배열의 두 번째 항목 만 카트에 삽입했습니다. 왜? –

답변

0

는 더 나은 방법을 사용할 것이다.

관련 문제