Extract_attrib is a PHP script function that extracts the attributes of an image tag , which is extracted using the regular expression method.
This is useful when you want to extract image data from an IMG tag in HTML.
If you know how to modify a regular expression, then the same functionality is extended and can be used to extract any other HTML tags!
Just a few lines of code and hope it works for everyone.
To Extract the IMG tag properties using PHP, follow these steps
functionExtract_attrib ($tag) { Preg_match_all('/(ID|ALT|TITLE|SRC) = ("[^"]* ")/I ',$tag,$matches); $ret=Array(); foreach($matches[1] as $i=$v) { $ret[$v] =$matches[2] [$i]; } return $ret;} $img _tag= ' ; $atts= Extract_attrib ($img _tag);Print_r($atts);
return results
Array ( = "logo" = "Http://www.devdo.net/wp-content/uploads/2015/06/2015-06-02.jpg" = "Code Farm soldier" = "Code Farm Soldier Logo")
How PHP extracts img Tag Properties