0
1

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 3 years have passed since last update.

文字列を配列に、配列を文字列にする

Posted at

学習記録

#前提条件
・PHP version 5.4

#配列⇔文字列 
・implode
・explode

##implode
配列を文字列にする

書式
$変数=implode('配列の要素をつなげたい文字', 配列);
builtin.php
$input = [10, 20, 30];
echo implode('-', $input);
//結果 : 10-20-30

##explode
文字列を配列にする

書式
$変数=explode('どの区切りで配列にするか', 文字列);
builtin.php
$input = '10:20:30';
print_r(implode(':', $input));
//結果 : Array ( [0] => 10 [1] => 20 [2] => 30 )
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?