พี่ๆ ครับ ขอถาม php หน่อยครับ ติดอยู่ นิดเดียว

function clean_url($title,$skip_spacer=null)
{
	unset($ntitle);
	$ntitle = trim($title);
	$ntitle = urldecode($ntitle);
	$ntitle = strip_tags($ntitle);
	$ntitle = html_entity_decode($ntitle);

	$ntitle = $this->str_char_replacement($ntitle);
	$ntitle = strtolower($ntitle);
	$ntitle = preg_replace('/\^|"|\'/','',$ntitle);
	$ntitle = preg_replace('/&.*?;/','',$ntitle);
	$ntitle = preg_replace( "/[^0-9a-zA-Zก-๙]/", ',', $ntitle );

	$spacer = ($skip_spacer)?$skip_spacer:$this->ipsclass->vars['mseo_seperator'];

	$ntitle = $this->ipsclass->clean_comma( $ntitle );
	$ntitle = $this->ipsclass->trim_trailing_comma( $ntitle );
	$ntitle = $this->ipsclass->trim_leading_comma( $ntitle );
	$ntitle = str_replace(',',$spacer ,$ntitle);


	return $ntitle;
}

นี่คือ code แปลงให้ ชื่อกระทู้ ไปเป็น seo url อะครับ มันจะกรอกพวกสัญลักษณ์ แปลกๆ ออกไป รวมถึงภาษาไทยด้วย

ผมลองแก้

	$ntitle = preg_replace( "/[^0-9a-zA-Z]/", ',', $ntitle );

เป็น

		$ntitle = preg_replace( "/[^0-9a-zA-Zก-๙]/", ',', $ntitle );

มันก็ไม่ได้อะครับ

ทำยังไงดี

มันมีปัญหาตรงนี้อีก

url มันเป็น

http://bbs.sci.in.th/physics-%BF%D4%CA%D4%A1%CA%EC-f7.html

แทนที่จะเป็น

http://bbs.sci.in.th/physics-ฟิสิกส์-f7.html

ปล. ตอนนี้ผมแก้มาเป็น

function clean_url($title,$skip_spacer=null)
{
	unset($ntitle);
	$ntitle = trim($title);
	$ntitle = urldecode($ntitle);
	$ntitle = strip_tags($ntitle);
	$ntitle = html_entity_decode($ntitle);

	$ntitle = $this->str_char_replacement($ntitle);
	$ntitle = strtolower($ntitle);
	$ntitle = preg_replace('/\^|"|\'/','',$ntitle);
	$ntitle = preg_replace('/&.*?;/','',$ntitle);
//$ntitle = preg_replace( "/[^0-9a-zA-Z]/", ',', $ntitle );	
	$ntitle = ereg_replace("[[:space:]]+", ",", trim($ntitle));
	$ntitle = str_replace("-", ",",urldecode($ntitle));

	$spacer = ($skip_spacer)?$skip_spacer:$this->ipsclass->vars['mseo_seperator'];

	$ntitle = $this->ipsclass->clean_comma( $ntitle );
	$ntitle = $this->ipsclass->trim_trailing_comma( $ntitle );
	$ntitle = $this->ipsclass->trim_leading_comma( $ntitle );
	$ntitle = str_replace(',',$spacer ,$ntitle);


	return $ntitle;
}

แล้ว มันมีปัญหาเหมือนกับ rep บนอะครับ

ต้องใช้ unicode ครับถึงจะแสดงเป็นภาษาไทย

(แต่ google แยกออกนะ)

หมายถึง utf8 เหรอครับ

แต่จริงๆ ปัญหามันคือ พอขึ้นแบบนั้นแล้วมัน error อะครับ

มัน error แบบไหนเหรอครับ