หากต้องการลบเครื่องหมายจุลภาค คุณเปลี่ยนได้ หากต้องการแทนที่ ให้ใช้ 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,"<br>";
echo "After removing the comma(,)=",$result,"<br>";
?>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้
The actual value is=John,Smith After removing the comma(,)=JohnSmith