Code mnemonics: PHP implode/explode Jun22 '05
I’ve come up with some mnemonics for remembering the difference between the PHP functions, implode and explode, since I always confuse them, in my head.
First, their function
implode
implode acts on an array, and returns a
string:
$array = ("Oasis", "Coldplay", "Foo Fighters");
$string = implode(", ", $array);
echo $string;
The above code outputs:
Oasis, Coldplay, Foo Fighters
explode
explode acts on a string, and returns an array:
$string = "Oasis, Coldplay, Foo Fighters";
$array = explode(", ", $string);
echo $array[0];
The above code outputs:
Oasis
Mnemonics
Here’s a couple mnemonics relating to these PHP functions:
I Am String
Easy String i Am
The first line above (I Am String) translates to: Implode Array String (using the first letters). This further translates to: Implode acts on Array, and returns a String.
The second line above (Easy String i Am) translates to: Explode String Array (using the capital letters). This further translates to: Explode acts on String, and returns Array.
I Am Easily Separated
This contains both implode and explode mnemonics in the same line.
Just use the first letters: Implode Array Explode String.
Personally, I like the first mnemonic better. Even though it is two lines, as opposed to one, it is easier to remember, and even contains the word easy, which is similar to Microsoft employees only owning Dell digital music players, rather than iPods – a competitor.
Categories: Efficiency
, PHP ![]()
Add Feedback (view all)
Leave feedback
The implode equivalent in javascript is called "join" ... Read more.
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Similar Entries
- PHP: Skipping index page call in URL (200 recent visits)
- PHP project: convert times to numbers (421 recent visits)
- PHP – passing variables across pages (11893 recent visits)
- Install Apache, PHP, MySQL on Windows (221 recent visits)
- Swap banner image with CSS and PHP (797 recent visits)
- PHP date formatting ass backwards (208 recent visits)
Stats
517 unique visits since August 2008
Recent Referrers (click)
- php implode
- difference between explode and split
- php implode java
- java Split string at capital letters
- java implode function
- java split implode
- php explode any letter
- php implode explode
- difference between join and implode php
- Java implode
- php explode string to letters
- java implode
- java implode
- difference between explode and split function with example
- php explode implode
- java implode
- implode explode java
- php split string on capitals
I prefer "split" to "explode", which is what Java and Javascript and some other languages use. Don't think there's any built-in "implode" function ... Read more.