Jan 11, 2009 by Matt | Posted in Coding
Explode() is a widely-used PHP string function that is also one that tends to mystify beginners looking at others’ code. It’s a nifty little function that you may find plenty of uses for once you know how it works.
Explode() takes two arguments, a delimiter and the string you wish to operate on, then returns an array. The function splits a string into multiple pieces at the delimiter, and puts each piece into a numerical array.
Have a list of comma-separated words? (A scenario increasingly common now that “tagging” has become such a popular device.) You can pass a comma-delimited string to explode() with a delimiter of “,” and voila, you have an array containing each of the items.
$string = "lorem, ipsum, dolor";
$delimiter = ", ";
$array = explode($delimiter, $string);
Now you have a single-dimension numerical array with each list item in it.
$array would contain “lorem” and
$array would be “ipsum” and so on.
Continue reading →
Thaya Kareeson from Omninoggin recently pointed me in the direction of a site called AdBlock.org, a site that seems to have a similar view of of ad blockers as my own. Adblocking software is a response to abusive activity by advertisers. It’s the continuation…
This month’s featured WordPress theme is “Desk Space” by Dirty Blue Media.
StylizedWeb has an interesting post up on increasing the number of comments on your posts. It covers a lot of ground, and has some tips worth trying. Engaging Readers, Design Your Way to More Blog Comments First the post explains why people comment, and…
I was trawling through the PHP function reference the other day, looking for some information on regular expressions, when I happened across this gem: $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" rel=\"nofollow\">\\0</a>", $text); It may look like gibberish at first, but if you look at it…
It’s 2009 now, which means it’s time to update an important part of your website that is easy to overlook: The copyright notice in your footer. If you haven’t already updated the line of text, which should read something along the lines of “©2009…
If you have already updated to WP125 version 1.2.0, which was released just a few days ago, you would be strongly advised to upgrade to the the new 1.2.1 release, which fixes a critical bug. If you are running 1.2.0, ads will not be…