Making unique function?
<p>I have this YouTube thumbnail/title grabber, inside my message system.</p>

<p>So when a message contains a YouTube link it shows it in a div element.</p>

<pre><code>&lt;script&gt;
    function youtubeFetchDataCallback(data) {
        var s = '';
        s += '&lt;br/&gt;';
        s += '&lt;a href="' + data.entry["media$group"]["media$player"].url + '" target="_blank"&gt;&lt;img src="' + data.entry["media$group"]["media$thumbnail"][0].url + '" width="' + data.entry["media$group"]["media$thumbnail"][0].width + '" height="' + data.entry["media$group"]["media$thumbnail"][0].height + '" style="float: left; margin-right: 10px;"&gt;&lt;/a&gt;';

        s += '&lt;strong&gt;' + data.entry["title"].$t + '&lt;/strong&gt;&lt;br/&gt;';

        s += '&lt;br/&gt;' + data.entry["media$group"]["media$description"].$t.replace(/\n/g, '&lt;br/&gt;') + '&lt;br/&gt;';
        s += '&lt;div class="clearfloat"&gt;&lt;/div&gt;';
        $('.youtubeDataFetcherOutput').html(s);
    }
&lt;/script&gt;
&lt;?php
    $isY = preg_match("#(?&lt;=v=)[a-zA-Z0-9-]+(?=&amp;)|(?&lt;=[0-9]/)[^&amp;\n]+|(?&lt;=v=)[^&amp;\n]+#", $content, $matches);

    if($isY){
        foreach($matches as $m){
        ?&gt;
        &lt;script&gt;
            $.getScript( 'http://gdata.youtube.com/feeds/api/videos/&lt;?php echo $m; ?&gt;?v=2&amp;alt=json-in-script&amp;callback=youtubeFetchDataCallback' );

        &lt;/script&gt;
        &lt;?php
    }
} ?&gt;
</code></pre>

<p>I have this, which works fine until there's two messages in one page, with YouTube links. Then they sends the same <code>$.getScript()</code>, and therefore both returns with same video thumbnail and title. How can I make them unique?</p>

<p>Each message has a id stored in <code>$row['id']</code>, so maybe it will be something like sending the unique id, with the callback, and then handle them both different ways. Just a thought, as I'm not sure..</p>

<p>(I used foreach, as $matches returns out as a array)</p>

<p>How can this be done?</p>
