ขอความช่วยเหลือ php เรื่อง nofollow

เริ่มโดย workshop, 13 กันยายน 2007, 13:33:34

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

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

workshop

ตามกระทู้นี้ครับ http://www.thaiseoboard.com/index.php/topic,14903.0.html

ผมลองทำดูโดยใช้


<?
$text = "which give the discerning audio enthusiast some respite in their travels, or, for the audiophile who accepts nothing less than the best, a world class entertainment system that?s worthy of any classy whip. Happy travels!</p><p>Nathan Kartchner is the Marketing Coordinator for Sewell Direct, a premium online retailer, where you can find the <a target="_new" href="http://sewelldirect.com/vr3-cd-player-usb-port-audio-input-mp3.asp">VR3 Car Stereo CD Player with USB Port and Auxiliary Connector</a>, the <a target="_new" href="http://sewelldirect.com/vr3-thumbdrive-dj-mp3-fm.asp">VR3 Thumbdrive Player/FM Transmitter</a>, and the <a target="_new" href="http://sewelldirect.com/Scosche-iPod-Bluetooth-Car-Kit.asp">Scosche iPod Wireless Bluetooth Car Kit</a>"

$pattern = '/<a href=/';
$replacement = '<a rel="nofollow" href=';
$text = preg_replace($pattern,$replacement, $text);
echo $text;
?>


มันติดตรงที่ใน $textมันมีเครื่องหมาย " อยู่เต็มไปหมด
เลยคิดว่า ถ้าผมนั่งไล่แก้ ผมไล่ใส่ rel="nofollow" ง่ายกว่าครับ

จึงอยากจะขอคำแนะนำด้วยครับเอายังไงดี

EThaiZone

มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)

desiger

อ้างถึงจาก: EThaiZone ใน 13 กันยายน 2007, 15:07:39
มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)

EOF เพิ่งรู้อ่ะว่ามี และก้ใช้กันง่ายๆอย่างงี้ได้ด้วย

ขอบคุงครับ
มาอัพเดท [direct=http://www.nod32ze3.com]NOD32[/direct] รหัส NOD32 Username Password NOD 32 กันครับ [direct=http://fundz3.bloggang.com][/direct] [direct=http://my.dek-d.com/dlzdekd/blog][/direct]

workshop

อ้างถึงจาก: EThaiZone ใน 13 กันยายน 2007, 15:07:39
มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)


ขอบคุณมากๆ ครับ
กำลังปวดหัวอยู่เลย
ตอนนี้แก้ไขอยู่ติดขัดอะไรคงต้องรบกวนอีกครั้งครับ
ถ้าเป็นไปได้จะขอ msn ของคุณ EThaiZone ได้ไหมครับ
เห็นแจกหลายคนแล้ว ขอเพิ่มอีกซักคน