เพื่อลบคอมม่า คุณสามารถแทนที่ได้ ใช้ str_replace() ใน PHP
สมมติสตริงอินพุตของเราที่มีคอมม่าคือ
$name="John,Smith";
เราต้องการเอาต์พุตหลังลบคอมมาจากสตริงข้างต้นคือ
JohnSmith
ตัวอย่าง
โค้ด PHP ดังนี้
<!DOCTYPE html> <html> <body> <?php
$name="John,Smith";
$result = str_replace(',', '', $name);
echo "The actual value is=",$name,"
";
echo "After removing the comma(,)=",$result,"
";
?> </body> </html>
ผลลัพธ์
นี่จะผลิตเอาต์พุตดังนี้
The actual value is=John,Smith After removing the comma(,)=JohnSmith