preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

PHP Result Center PHP Result Center เป็นหมวด ที่ไว้รวบรวม โปรแกรม Code php Javascript CSS CMS

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

preg_match_all หาเบอร์โทร จาก tag html หรือจะหา e-mail ลิงค์ css
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;
}
 
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

โค้ด: เลือกทั้งหมด

// retrieve keywords
function get_keywords($file){
$h1tags = preg_match('/(<meta name="keywords" content="(.*)" \/>)/i',$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return $res;
} 
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

โค้ด: เลือกทั้งหมด

// retrieve link destinations
function get_a_href($file){
$h1count = preg_match_all('/(href=")(.*?)(")/i',$file,$patterns);
return $patterns[2];
}

// get count of href's
function get_a_href_count($file){
$h1count = preg_match_all('/<(a.*) href=\"(.*?)\"(.*)<\/a>/',$file,$patterns);
return count($patterns[0]);
}
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

โค้ด: เลือกทั้งหมด

// retrieve spans on the site
function get_script($file){
$h1count = preg_match_all('/(<script.*>)(.*)(<\/script>)/imxsU',$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return $res;
}
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

โค้ด: เลือกทั้งหมด

// retrieve images on the site
function get_images($file){
$h1count = preg_match_all('/(<img)\s (src="([a-zA-Z0-9\.;:\/\?&=_|\r|\n]{1,})")/isxmU',$file,$patterns);
$res = array();
array_push($res,$patterns[3]);
array_push($res,count($patterns[3]));
return $res;
}
 
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41230
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

โค้ด: เลือกทั้งหมด

// retrieve any email
function get_emails($file){
$h1count = preg_match_all('/[a-zA-Z0-9_-]{1,}@[a-zA-Z0-9-_]{1,}\.[a-zA-Z]{1,4}/',$file,$patterns);
$res = array();
array_push($res,$patterns[0]);
array_push($res,count($patterns[0]));
return $res;
}
 
function นี้ยังมีปัญหากับ mail เช่น .co.th
ให้แก้ reg โดยเพิ่ม \. เพื่อมเข้าไป
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
pjgunner
PHP Jr. Member
PHP Jr. Member
โพสต์: 24
ลงทะเบียนเมื่อ: 16/08/2010 2:55 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย pjgunner »

ไม่ทราบว่า mxsU ที่เป็นโมดิฟายเออร์ ในแพทเทอร์น หมายความว่าไงบ้างคับ
ภาพประจำตัวสมาชิก
imsn
PHP Super Member
PHP Super Member
โพสต์: 375
ลงทะเบียนเมื่อ: 07/05/2010 12:58 pm
ติดต่อ:

Re: preg_match_all หาเบอร์โทร tag html ไม่ว่าจะเป็น e-mail ลิงค์ css

โพสต์ที่ยังไม่ได้อ่าน โดย imsn »

ผมรู้แต่ /i แปลว่าฉันไม่สนตัวเล็กตัวใหญ่
ช่วยตอบเพราะอยากโปรโหมทเว็บ คิคิคลิกเลย
หาเพื่อนฝรั่งคุย M ...
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 58