0
0

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 1 year has passed since last update.

phpで改行ごとに配列で分ける方法

Posted at

はじめに。

備忘録。

コード

explode('\n',$mojis);

説明

explode()関数は区切り文字ごとに配列に分ける働きをします。例えば、

$moji = "東京,神奈川,埼玉,千葉,茨城";

という文字列に

explode(',',$moji);

とすると、

array('東京','神奈川','埼玉','千葉','茨城');

というふうに返ってきます。

なので、区切り文字に改行を表す\nを入れてあげれば、改行ごとに配列になって出てくるわけです。

終わりに

データベースが使えない案件つらい...

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?