Please help me with regexp

Discussion in 'PHP' started by fdoze, Mar 26, 2012.

  1. #1
    Hi,

    can you please help to transform this:

    <span style="display:none;"  allowFullScreen="true" src="http://server.com/video.mp4" width="400" height="350"></span><br/>Â <br/>Â <br/><div align="center"><span style="display:none;"  allowFullScreen="true" src="http://server.com/video.mp4" width="400" height="350"></span>
    PHP:
    into this:

    <video width="320" height="240" controls="controls">
      <source src="http://server.com/video.mp4" type="video/mp4" />
      Your browser does not support the video tag.
    </video>
    PHP:


    I want to use preg_match replace and use the video url but I need help setting regular expression...

    Thanks.
     
    fdoze, Mar 26, 2012 IP
  2. trecords

    trecords Well-Known Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    Try this:

    $html = '<span style="display:none;"  allowFullScreen="true" src="http://server.com/video.mp4" width="400" height="350"></span><br/>A <br/>A <br/><div align="center"><span style="display:none;"  allowFullScreen="true" src="http://server.com/video.mp4" width="400" height="350"></span>';
    
    preg_match('#<span style="display:none;"  allowFullScreen="true" src="(.*?)"#', $html, $out);
    
    echo '<video width="320" height="240" controls="controls">
      <source src="'.$out[1].'" type="video/mp4" />
      Your browser does not support the video tag.
    </video>';
    PHP:
     
    trecords, Mar 27, 2012 IP
  3. fdoze

    fdoze Peon

    Messages:
    205
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'll try. Thanks.
     
    fdoze, Mar 27, 2012 IP