Wednesday, January 28, 2009

Explode function to divide string

This will show explode function .
it will divide the string into number of chunks


$someWords = "Please don't blow me to pieces.";

$wordChunks = explode(" ", $someWords);
for($i = 0; $i < count($wordChunks); $i++){ echo "Piece $i = $wordChunks[$i]
";
}

$wordChunksLimited = explode(" ", $someWords, 4);
for($i = 0; $i < count($wordChunksLimited); $i++){ echo "Limited Piece $i = $wordChunksLimited[$i]
";
}

No comments:

Post a Comment