Jump to content

Recommended Posts

hello guys i have a problem. All i want is to pass my information coming from my multidimensional array. I try to create a function named r_implode that extract array into string but i dont know how to put it in the database.

 

here's my code hope you can help me.

 


//get array information
$products = unserialize($this->session->userdata('product_list'));

//print array information, works well
foreach($products as $element => $inner_array){
       echo "<strong>Product ID: ".$element."</strong><br>";
       foreach($inner_array as $items){
           echo $items."<br>";
       }
}


//HOw CAN I PASS THE ARRAY INFORMATION TO MY DATABASE?

//extract array into string works well

function r_implode( $glue, $pieces ){ 
    foreach( $pieces as $r_pieces ){ 
     if( is_array( $r_pieces )){ 
       $retVal[] = r_implode( $glue, $r_pieces ); 
     }else{ 
       $retVal[] = $r_pieces; 
     } 
    } 
    return implode( $glue, $retVal ); 
   } 
   echo r_implode(',',$products)."\n";

 

example of my array layout:

 

Product ID: 2

2

NOKIA 5110

Cellphone

500.00

1

500

NOKI2012-84353

Product ID: 3

3

HP IPAQ RW6828

Cellphone

1500.00

1

1500

HP I2012-08386

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.