<?php $str = "Hello world. It's a beautiful day."; print_r (explode(" ",$str)); ?> try add these: <?php $str = "Hello world. It's a beautiful day."; echo'<pre>'; print_r (explode(" ",$str)); echo'</pre>'; ?> The <pre> HTML tag defines preformatted text. Text in a pre element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks . link