Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP regular expression for getting image source from anchor tag
    primarykey
    data
    text
    <p>I need help to get the image source from image tab which is comprised into an anchor tag, e.g.</p> <pre><code>&lt;p&gt;this is sample text &lt;a href="a link to some site"&gt;&lt;img src="imagesource" height='x' width='y' /&gt;&lt;/a&gt;&lt;p&gt; </code></pre> <p>from above text string I want to retrieve the image source.</p> <p>here is the actual description from which I have to extract the source for <strong>first image tag only</strong> </p> <pre><code>$desc = "&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href='http://somesitename.com/wp-content/uploads/2007/08/100_2666.JPG' title='100_2666.JPG'&gt;&lt;img width=\"400\" src='http://somesitename.com/wp-content/uploads/2007/08/100_2666.JPG' alt='100_2666.JPG' /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href='http://somesitename.com/wp-content/uploads/2007/08/100_2667.JPG' title='100_2667.JPG'&gt;&lt;img width=\"400\" src='http://somesitename.com/wp-content/uploads/2007/08/100_2667.JPG' alt='100_2667.JPG' /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;These are some of the variations of cotton floral prints used by the Knickerbocker Toy Co. in the 1960's. I constantly search for more examples of the unusual early prints and sometimes have to purchase a doll in fair condition just to have her dress!! See the article about the Knickerbocker Anns that follows.&lt;/p&gt;"; $imgsrc_regex = '/&lt;a (.*)&gt;&lt;img.+?src=(\'|")(.+?)(\'|")[^&gt;]*&gt;&lt;(.*\/)*a&gt;/'; preg_match($imgsrc_regex, $desc, $arr_match_array); </code></pre> <p>The above arr_match_array returns all anchor image tags where as I want to get only the first</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload