Jump to content

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

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.