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
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of 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.
Popular Pages
- Fast rounded corners in Photoshop (7873 recent visits)
- PHP – passing variables across pages (2857 recent visits)
- JavaScript set selected on load (2345 recent visits)
- Removing all child nodes from an element (1704 recent visits)
- iPod songs out of order? (1412 recent visits)
- Firefox 3 smart address bar: wildcard search (1300 recent visits)
- Britney - Everytime piano tab (1180 recent visits)
- MySQL LEFT JOIN syntax (971 recent visits)
- Breathe Me - Sia (824 recent visits)
- Tumblr: how blogging should be (727 recent visits)
Similar Entries
- PHP: Skipping index page call in URL (47 recent visits)
- PHP project: convert times to numbers (107 recent visits)
- PHP – passing variables across pages (2857 recent visits)
- Install Apache, PHP, MySQL on Windows (36 recent visits)
- Swap banner image with CSS and PHP (243 recent visits)
- PHP date formatting ass backwards (49 recent visits)
Stats
110 unique visits since August 2008
Recent Referrers (click)
- and explode php
- new line php implode
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- what is difference between implode and explode
- php date explode implode
- array explode
- java string explode implode
- php explode and implode
- what is the difference between explode and implode
- what is the difference between explode and implode
- what is the difference between explode and implode in php
- javascript implode
- php explode letters
- php search implode array
- explode letters php
- java implode like php
- JAVA implode array to string function
- Java implode
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.