다음이 우리의 문자열 배열이라고 가정해 봅시다 -
$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