Strip particular html tag

Discussion in 'PHP' started by Smaug, Aug 21, 2007.

  1. #1
    Hi, I have this problem, I have bunch of html files and I need to extract contents of <embed> tag in each file... I can do the file opening etc alone but I dont know about the tag thing, can you suggest me some php function or method?
    Thank you
     
    Smaug, Aug 21, 2007 IP
  2. tubiron

    tubiron Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could try something like this:

    $begin = strPos($htmlContent, '<embed>');
    $end = strPos($htmlContent, '</embed>');
    $extracted = substr($htmlContent,$begin,($end - $begin));
     
    tubiron, Aug 21, 2007 IP
  3. Smaug

    Smaug Peon

    Messages:
    374
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes! It works, thank you.
     
    Smaug, Aug 21, 2007 IP
  4. alexts

    alexts Well-Known Member

    Messages:
    1,126
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    1
    #4
    preg_match_all('|<embed[^>]*?>(.*?)</embed>|si',$html,$matches);
     
    alexts, Aug 21, 2007 IP
  5. deriklogov

    deriklogov Well-Known Member

    Messages:
    1,080
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Is there any software for windows which would do the same and save that extraction to file ? ( plus crawling one site)
     
    deriklogov, Aug 28, 2007 IP