simplexml - How to Extract the URL from A String in PHP? -
I am using PHP's "simplexml_load_file" to get some data from Flickr.
My goal is to get a photo url
I am able to get the following value (specified in PHP variable):
How can I remove this part?
http://farm3.static.flickr.com/2298/ 2302759205_4fb109f367_m.jpg
In case of bus it helps , Here's the code I'm working with:
entry $ as child) {$ Flickr_content = $ child-> material; // img // url // html becomes / how can i get img url from "$ flickr_content" ??? }? & Gt;
You probably can use a regular expression for it, the formation of HTML If there is a lot more going on, like:
if (preg_match ('/ / lt; img src =' ([^ "+]" / i ', $ string, $ Matches)) {$ imageUrl = $ matches [1];}
This is quite unsafe, and if the HTML is changing (such as the parameters of the parameters & lt; img & Gt;
tag, the risk of perverted HTML etc.), then it would be better to use an HTML parser.
Comments
Post a Comment