I need a php function that will insert randomly a youtube video, html link, image or anything else into an article. The function must check it's not inserting the video/link/image/etc into an existing video/link/image already in the article.
The php function will be like the one below where $article is the article which may already contain images/videos/links and $element is the video/image/link that needs to be randomly inserted into the article.
function insertelement($article, $element){
return $article;
}