I see implode/explode used all the time!  as far as i know all they do is break up strings and put them together?  how come there used so much?  I cant think of to many uses for them. :(
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xakemSoftware Application DeveloperCommented:
this functions very helpful for manipulating string parts, as for me they are sometime dates, sometime cookies or session variables...encode/decode... i can't remember all of the cases.
as HTML does not have a datatype for arrays, you use implode to make your PHP-datastructure to fit into HTML. When you get those values from HTML you split the mim explode into a PHP-array as it is easyer to work with array than with string delimited by a special character.
chilled2003Author Commented:
anymore common uses for it?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

chilled2003Author Commented:
hmmm so implode, explode is mostly used to put data in and out of arrays?
Their purpose is working with arrays, explode breaks up a string into an array using a string seperator character and implode joins array items together using a string glue character.


Explode: string to array
Implode: array to string

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

$string = "hello|there|i|am|a|string";

$parts = explode("|",$string);

Parts is now an array: Array ( [0] => hello [1] => there [2] => i [3] => am [4] => a [5] => string )

$outstring = implode(" ",$parts);

Out string joins the array items together with spaces forming the string: hello there i am a string
I have not much to add to the things Diableo84 said.

I often use it to implode the results from the file function. But this can all be skipped when using filegetcontents() instead of implode('', file());

I relation to session you could use implode to store the session data (of parts of it) if you are sure it are all numeric values or all string values. Then you can implode things before storing to gain a string like "1,2,3,4" and when restoring your session just explode it back into an array. But then again, you would probably use serialize.

One thing I use implode a lot, is when i have an array of strings and want to output it as table cells or list items:

echo '<tr><td>'.implode('</td><td>', $data).'</td></tr>';
echo '<li>'.implode('</li><li>', $data).'</li>';

This saves a lot of typing, and i guess there are more ways to easily output arrays of data.

chilled2003Author Commented:
Roonaan thanks for the extra info :D
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.