4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

文字列から配列に変換(explode)と配列から文字列に変換(implode)

Last updated at Posted at 2014-01-31

文字列から配列に変換(explode)

explode
//explode('区切り文字','対象文字列')
$a = explode('|','aa|bb|cc');
var_dump($a);
表示結果
array(5) {
  [0]=>
  string(2) "aa"
  [1]=>
  string(2) "bb"
  [2]=>
  string(2) "cc"
}

※splitは非推奨のため、文字列で文字列を分割する場合は、explodeを使用する。

配列から文字列に変換(implode)

implode
//implode('区切り文字','対象配列')
$s = implode('|',array('aa','bb','cc'));
var_dump($s);
表示結果
string(8) "aa|bb|cc"
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?