ผมใส่แบบนี้แล้วใช้ไม่ได้ครับ PHP ครับ

เริ่มโดย a8, 26 เมษายน 2013, 22:13:21

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

a8

ผมใส่แบบนี้แล้วใช้ไม่ได้ครับ

<?
$var1 = ereg_replace('.',"",xxxx.xxxx);
echo $var1
?>

เรียกดูมันใช้ไม่ได้เลยครับ ทำยังไงผมจะเอาจุดออกได้ครับ แล้วมันมาติดกัน
ถ้าใส่ตัวอักษรไปที่จุดด้วย มันจะแสดง แต่ถ้าใส่จุดอย่างเดียวมันไม่แสดงเลย

ทำยังไงครับ

cyberspace

จะเอาจุดออกจาก String ใช่ไหมครับ

ลองแบบนี้ครับ

<?
$var1 = str_replace(".", "", "xxxx.xxxx");
echo $var1
?>

a8


xvlnw.com

เสริมให้ครับ str_replace ใช้ตัวแปรแบบ Array ได้ด้วยนะ ในกรณีอยาก replace หลายๆค่าครับ

str_replace(Array_Search, Array_Replace, Text);

:wanwan003:
[direct=https://cloudhost.in.th/wordpress-hosting]ツ ⓌⓄⓇⒹⓅⓇⒺⓈⓈ ⒽⓄⓈⓉⒾⓃⒼ [/direct] :wanwan014:  :D
[direct=https://cloudhost.in.th/cloudhosting.html]Cloud Hosting[/direct] [direct=https://cloudhost.in.th/cloudvps.html]Cloud Server[/direct] [direct=https://cloudhost.in.th/vpshosting.html]Cloud VPS Hosting[/direct] [direct=https://cloudhost.in.th/windowsvps.html]Cloud Windows[/direct] Tel: 080-348-0843 LINE: ixvlnw

dotnetz

ereg_replace มันใช้ regular expression ในการ replace ครับ ซึ่งจะเป็นลักษณะของ pattern
และคุณต้องรู้วิธีการเขียน regular expression ด้วยครับ

ถ้าแค่ replace "." ธรรมดา ใช้ str_replace ตามน้าๆข้างบนบอกครับ
[direct=http://www.thaiseoboard.com/index.php/topic,347531.0.html]...เริ่มต้นจากเงิน 500 บาท...[/direct]
[direct=http://www.thaiseoboard.com/index.php/topic,301349.0.html]+++ ครบ 18 เดือนกับการลุยป่า มาแชร์กัน +++[/direct]
HOST25GATOR <= คูปองโค้ด โฮสเกเตอร์ จัดเต็ม!! ลด 25% ทุกแพลน