mercredi 1 avril 2015

How to get the names of files present in tags from a string and create an array of all those file names in PHP? [duplicate]


This question already has an answer here:




I've one sample string as follows :



$feed_status = Nice to see you all back again <img src=\"http://ift.tt/1BZQwnH\" alt=\"Smile\" title=\"Smile\" title=\"v_middle\" /><img src=\"http://ift.tt/1BZQwnH\" alt=\"Smile\" title=\"Smile\" title=\"v_middle\" /><img src=\"http://ift.tt/1BZQwnH\" alt=\"Smile\" title=\"Smile\" title=\"v_middle\" />;


(Forgive me for syntactical errors like placing of single quotes and double quotes)


For your reference I've just added three <img> tags to the string but in real situation ths string could contain a single <img> tag or no <img> tag or more than one <img> tags.


I want to get names of files present in each of the <img> tag's src attribute and make array of those file names.


In this case the resultant array should be as follows :



$new_arr = {smile.png, smile.png, smile.png};


How should I do this in an optimum way using PHP?


Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire