2
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.

Laravelで、Array to string conversion in …. と出たときの解決策

Last updated at Posted at 2020-11-02

エラー

terminal
local.ERROR: ErrorException: Array to string conversion in ….

原因は配列型(Array)を文字列型(String)に変換できないこと。

解決策

implodeを使用して配列を展開する。

.php

$array = array('name', 'email', 'age');
$conversion = implode(",", $array);

echo $conversion; // name,email,age

単純に配列を文字列に変換したいときには便利なメソッドでした。

参考文献

implode - PHP

会社の紹介

私は現在、株式会社ダイアログという物流×ITの会社に勤務しております。
2020年11月現在、エンジニアの募集はしていませんが、他にも様々な職種を募集しているので、Wantedlyのページをご覧ください。

2
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
2
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?