Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created January 29, 2017 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/b01960d50d4b97c4ec8037b7a3b3d118 to your computer and use it in GitHub Desktop.
Save phpfiddle/b01960d50d4b97c4ec8037b7a3b3d118 to your computer and use it in GitHub Desktop.
[ Posted by Mohammad ] Convert Tag img to array
<?php
/**
* Convert Tag img to array
* (src) OR (src|alt|class|...)
**/
$img_tag = '<img class="vote-up" src="/content/img/vote-arrow-up.png" alt="vote up" title="This was helpful (click again to undo)" />';
preg_match('/(src)=("[^"]*")/i',$img_tag, $src);
echo '<pre>';
print_r($src);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment