Regular Expressions 101

Regular expression in PHP to return array with all images from html

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
<img.*?src="([^"]+)".*?>
/
g

Description

<img.?src="([^"]+)".?>

Example:

preg_match_all('/<img.?src="([^"]+)".?>/', '', $arr, PREG_PATTERN_ORDER); Returns:

Array ( [1] => Array ( [0] => "lol" [1] => "wat" )

)

Submitted by Anonymous