如何在字符串数组中删除一个字符('')并在一个字符串中显示结果?
假设我们的字符串数组如下:
$full_name= '["John Doe","David Miller","Adam Smith"]';
我们希望输出的内容为一个字符串:
John Doe, David Miller, Adam Smith
为此,请使用 json_decode()。
示例
PHP 代码如下
<!DOCTYPE html>
<html>
<body>
<?php
$full_name= '["John Doe","David Miller","Adam Smith"]';
$full_name = json_decode($full_name);
$filterData = array_filter(array_map('trim', $full_name));
$output = implode(', ', $filterData);
echo "The Result in one string=",$output;
?>
</body>
</html>输出
它将生成以下输出
The Result in one string=John Doe, David Miller, Adam Smith
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP