文字列から配列に変換(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"