2016年7月22日 星期五

[PHP] How to use Explode , Implode in PHP

Explode Function (PHP)

Break a string into an array


<?php
  $str = "time,clock,book,money";
  print_r (explode(",",$str));
?>

Result:
Array ( [0] => time [1] => clock [2] => book [3] => money )




Implode Function (PHP)


Join array elements with a string

<?php
  $arr = array('We','are','family','.');
  echo implode(" ",$arr);
?>

Result:

We are family .




沒有留言:

張貼留言