Jump to content

Recommended Posts

My program is using several arrays (have over a thousand variables so arrays are a must).

 

At the moment I am simply exploding the arrays when needed and then imploding them if they need to be saved.

 

This morning I was thinking that maybe I should put each array into its own $_SESSION at the start of the program so I don't have to keep imploding and exploding them, except imploding them in order to save any changes.

 

Is there much difference in these two methods in the way it effects the server?

Link to comment
https://forums.phpfreaks.com/topic/160229-arrays-and-when-they-should-be-used/
Share on other sites

Well, if you save a string in the DB like:

"one, two, three" - explode that would get you an array ( 0 => "one", 1 => "two", 2 => "three") then implode that into something like "one - two - three"

 

don't ask why I'd do something like that, but it's possible somebody would want to. :P

I'm sure he meant exploding a string into an array and imploding back into a string.  But I'm sure you knew that, and you're just being an ass.  Stop it.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

That's my job.

Crayon Violent - I actually wanted to know what exploding an array would do. In my tests, they just come back as the original array. I would think PHP would give me an error, but it doesn't. ???

 

er.. well when you try to explode an array, for instance:

 

$x = range('a','z');
$y = explode(' ',$x);

 

explode evaluates it as a string of value "Array" and explodes the string based on the delimiter.

Exploding an array allows you to put a value from a database into an array of values.

 

For example if the database value is {Human, fighter, strong}

then it could be exploded to

abilities[0] = human

abilities[1] = fighter

abilities[2] = strong

 

this helps in putting variables together in values that are needed on the one page and not having to have a thousand differant fields in a database.

For me this system works fine, I'm just worried about putting strain on the server.

 

Note that this is just a simple example, the reality is that the values are a lot bigger.

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.