preg_match_all ดึงข้อมูลที่ต้องการ ออกจาก tag html ไม่ว่าจะเป็น e-mail ลิงค์ css
หรือ อื่นๆ สามารถประยุกคไปใช้ได้
เอาไปใช้ แทนเครื่อง หมาย ‘ เป็น ' หรือ " นะครับ
โค้ด: เลือกทั้งหมด
function get_doctype($file){
$h1tags = preg_match('/<!DOCTYPE (\w.*)dtd">/is',$file,$patterns);
$res = array();
array_push($res,$patterns[0]);
array_push($res,count($patterns[0]));
return $res;
}
โค้ด: เลือกทั้งหมด
// retrieve page title
function get_doc_title($file){
$h1tags = preg_match('/<title> ?.* <\/title>/isx',$file,$patterns);
$res = array();
array_push($res,$patterns[0]);
array_push($res,count($patterns[0]));
return $res;
}