Jump to content

Exploding arrays inside array. List separated by commas and vertical lines.


Repgahroll

Recommended Posts

Hello there!

 

I have the following list:

 

apple,banana,pear|applejuice,bananajuice,pearjuice|applepie,bananapie,pearpie

 

I can explode these to get:

array[0] = apple,banana,pear

array[1] = applejuice,bananajuice,pearjuice

array[2] = applepie,bananapie,pearpie

 

However, i want to get:

 

array[0][0] = apple

array[0][1] = banana

array[0][2] = pear

...

 

But i don't know how i can explode these items inside the array to get such result.

 

Thanks in advance.

Something like this?

 

$input = 'apple,banana,pear|applejuice,bananajuice,pearjuice|applepie,bananapie,pearpie';
$arr = explode("|", $input);
foreach($arr as $k=>$v) {
   $arr[$k] = explode(",", $v);	
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.