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. Continue reading →$array[0]
would contain “lorem” and $array[1]
would be “ipsum” and so on.
Design Your Way to More Blog Comments
Jan 7StylizedWeb 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…