Using the explode() and implode() Function
<?php $str = "Colonia De Sant Jordi."; $pieces = explode(" ", $str); echo "Nodes: <BR/>\n"; foreach($pieces as $name) { echo trim($name) . "<BR/>\n"; } ?>
Output:
Nodes:
Colonia
De
Sant
Jordi.
Colonia
De
Sant
Jordi.
Using explode() with date()
<?php $ar = explode('|',date("h a|F d, Y")); echo "It's after $ar[0] on $ar[1]"; ?>
Output:
It’s after 03 pm on November 04, 2011
Using implode()
<?php $arr[0] = "Colonia"; $arr[1] = "De"; $arr[2] = "Sant"; $arr[3] = "Jordi."; $str = implode(" ", $arr); print("$str<BR>"); ?>
Output:
Colonia De Sant Jordi.