Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this code:</p> <pre><code>function getDomain($html) { preg_match('`&lt;[^&gt;]*src=["\'\s]?([^"^\'^\s]+)["\'\s][^&gt;]*&gt;`i', $html, $matches); if(isset($matches[1])) return parse_url($matches[1], PHP_URL_HOST); return false; } $html = '&lt;iframe src="http://www.websites-test.com/video231/" frameborder=0 width=510 height=400 scrolling=no&gt;&lt;/iframe&gt;'; echo getDomain($html); echo '&lt;br /&gt;'; $html = '&lt;object width="990" height="750"&gt; &lt;param name="movie" value="http://www.websites-test.com/video231/"&gt;&lt;/param&gt;&lt;param name="AllowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.websites-test.com/video231/" type="application/x-shockwave-flash" wmode="transparent"` AllowScriptAccess="always" width="990" height="750"&gt;&lt;/embed&gt;&lt;/object&gt;'; echo getDomain($html); </code></pre> <p>Of course instead of <code>echo getDomain($html)</code> you can put <code>$Domain_Embed = getDomain($html)</code> to assing it to your variable, just as you wanted. <code>$html</code> is the HTML code that contains these tags with <code>src</code> that you mentioned.</p> <p>For multiple objects in the same <code>$html</code> you can change function to get array of results:</p> <pre><code>function getDomains($html) { $results = array(); preg_match_all('`&lt;[^&gt;]*src=["\'\s]?([^"^\'^\s]+)["\'\s][^&gt;]*&gt;`i', $html, $matches); if(isset($matches[1]) &amp;&amp; is_array($matches[1])) foreach($matches[1] as $match) $results[] = parse_url($match, PHP_URL_HOST); return empty($results) ? false : $results; } echo '&lt;pre&gt;' . print_r(getDomains($html), true) . '&lt;/pre&gt;'; </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      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