배열을 문자열로 변환하려면 PHP에서 implode() 개념을 사용하십시오. 다음이 우리의 배열이라고 가정해 봅시다 -
$sentence = array('My','Name','is','John'); 위의 배열을 문자열로 변환하려면 -
,implode(" ",$sentence) 예시
<!DOCTYPE html>
<html>
<body>
<?php
$sentence = array('My','Name','is','John');
echo "The string is=",implode(" ",$sentence);
?>
</body>
</html> 출력
The string is = My Name is John
이제 구분 기호도 추가할 또 다른 PHP 코드를 살펴보겠습니다. -
예시
<!DOCTYPE html>
<html>
<body>
<?php
$sentence = array('One','Two','Three');
echo "The string is=",implode("*",$sentence);
?>
</body>
</html> 출력
The string is = One*Two*Three