ในการแปลงอาร์เรย์เป็นสตริง ให้ใช้แนวคิดของ implode () ใน PHP สมมติว่าต่อไปนี้คืออาร์เรย์ของเรา –
$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