Jump to content

[SOLVED] Multiple arrays inside data


DanC

Recommended Posts

Hi,

 

Simple question. I have a column called "array" in my database, and inserted into each field is the following imploded array:

mctriangle,570.65,355.1,1,1,0

 

It is an instance of an object. Each field in each row contains this information as an imploded array.

 

[0] = Name

[1] =  X Axis

[2] = Y Axis

[3] = ScaleX

[4] = ScaleY

[5] = Rotation

 

When extracted from the database, it is exploded back into the array above.

 

As you can see, I would need to store a lot of rows for each object. Say we use 200 objects, thats 200 rows, which would be hard to search through.

 

My question is: Could I store multiple imploded arrays inside 1 row only. E.g:

 

mctriangle,570.65,355.1,1,1,0&&mctriangle,570.65,355.1,1,1,0&&mctriangle,570.65,355.1,1,1,0&&mctriangle,570.65,355.1,1,1,0&&mctriangle,570.65,355.1,1,1,0

 

The above would be 5 objects in one row of data, each imploded array separated by &&. How would I go about doing such a thing?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/181055-solved-multiple-arrays-inside-data/
Share on other sites

well firstly, you should look into serialize() if you want to put data structures (arrays, objects, etc) into tables. However, if you feel the need to put multiple different objects in one column, I suggest you rethink your database structure.

 

However, i suppose all you would need to do is do something like

$string = implode(',',$array1)."&&".implode(',', $array2);

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.