explode() is a really usefull PHP function, which I use all the time -- especially when combined
with list(), which is great when you have a know number of elements.
Let's say you're given a date 11/19/2003, but you only want the year:
It can also be used for breaking up text into single words:
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$words = explode(' ',$text);
// count words (rough)
$wordCount = count($words);
// maybe make sure each individual word is not too long
foreach($words as $key => $word)
{
if(strlen($word) > 100)
{
// word is ok
}
else
{
// word is suspect
}
?>
Similarly, you can implode() an array back into a string after you've played with the individual
parts: