Skip to content

Instantly share code, notes, and snippets.

@leonardop21
Forked from vyspiansky/image-src-regexpr.php
Created July 20, 2021 14:02
Show Gist options
  • Save leonardop21/7ca7788cd4be60c7f63f3ab95ead11b1 to your computer and use it in GitHub Desktop.
Save leonardop21/7ca7788cd4be60c7f63f3ab95ead11b1 to your computer and use it in GitHub Desktop.

Revisions

  1. @vyspiansky vyspiansky revised this gist May 8, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion image-src-regexpr.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    <?php

    // Source: http://goo.gl/qyLFbg

    $html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />';
  2. @vyspiansky vyspiansky renamed this gist Apr 25, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @vyspiansky vyspiansky renamed this gist Apr 25, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @vyspiansky vyspiansky renamed this gist Apr 25, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @vyspiansky vyspiansky created this gist Apr 25, 2014.
    12 changes: 12 additions & 0 deletions image-src.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <?php

    // Source: http://goo.gl/qyLFbg

    $html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />';

    preg_match( '@src="([^"]+)"@' , $html, $match );

    $src = array_pop($match);

    // will return /images/image.jpg
    echo $src;