【问题标题】:PHP array to string issue [closed]PHP数组到字符串问题[关闭]
【发布时间】:2014-02-23 09:40:33
【问题描述】:

您好,我在 PHP 中有一个数组,当我打印它时它是这样的:

["Testing","Test2","New Testing Activity","The last five letters in the alphabet"]

有没有办法制作这样的数组:

{"Testing","Test2","New Testing Activity","The last five letters in the alphabet"}

我想要这个'{' 而不是'['

谢谢

【问题讨论】:

  • 这不是 PHP 中的数组结构。请向我们展示您的代码,并告诉我们您想做什么来解决您的问题。

标签: php arrays


【解决方案1】:

也许你想做:

echo '{"' . implode('","', $arr) . '"}';

演示:http://phpfiddle.org/lite/code/p57-0u4

【讨论】:

  • 正是我整理的!干得好,@qwertynl!
猜你喜欢
  • 2021-05-31
  • 2023-03-15
  • 1970-01-01
  • 2013-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多