|
 |
|
การใช้ preg_match ในการดึง id มาแสดงมีวิีธีการอย่างไรบ้างแนะนำด้วยครับ |
|
 |
|
|
 |
 |
|
#\[youtube\:[0-9a-z]+\]([\-0-9_A-Za-z]+)\[/youtube\:[0-9a-z]+\]#
ใช้ regular expression ประมาณนี้ครับ
ที่เป็นสีดำคือ หาสิ่งนั้นตรงๆ เลย
ส่วนสีเขียวคือ หาตัวอักษร 0-9 และ a-z กี่ตัวก็ได้
และสีแดงคือ หา -, 0-9, _, A-Z และ a-z (รูปแบบของ Base64 for URL) และ "จับ" มันเข้ามาอยู่ใน array ที่ $matches (เพราะล้อมด้วยวงเล็บ)
ลองดูครับ
preg_match(
'#\[youtube\:[0-9a-z]+\]([\-0-9_A-Za-z]+)\[/youtube\]#',
'This is a cool video [youtube:27oo92ho]tkb-RVM1dLs[/youtube:27oo92ho] !!!',
$matches
);
print_r($matches);
// $matches[0] = [youtube:27oo92ho]tkb-RVM1dLs[/youtube:27oo92ho]
// $matches[1] = tkb-RVM1dLs
|
ประวัติการแก้ไข 2013-02-28 22:01:10 2013-02-28 22:02:26 2013-02-28 22:03:05
 |
 |
 |
 |
Date :
2013-02-28 22:00:29 |
By :
cookiephp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|