如何在字串陣列中刪除一個字元('')並在一個字串中顯示結果?
假設我們的字串陣列如下:
$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