Fügen Sie video tag zu youtube link von content hinzu

Ich habe variable $post->post_content , die mir Details von Post und einige Video- $post->post_content von YouTube zurückgeben.

Ich muss jeden Text von $post->post_content else YouTube-Link entfernen und zu YouTube likn dieses Tags hinzufügen

  

der content wie: –

 At this instant, while Daggoo, on the summit of the head, was clearing the whip—which had somehow got foul of the great cutting tackles—a sharp cracking noise was heard; and to the unspeakable horror of all, one of the two enormous hooks suspending the head tore out, and with a vast vibration the enormous mass sideways swung, till the drunk ship reeled and shook as if smitten by an iceberg. The one remaining hook, upon which the entire strain now depended, seemed every instant to be on the point of giving way; an event still more likely from the violent motions of the head. https://www.youtube.com/watch?v=JEreM0ZKY18 

und einige Zeit wie:

 أسر شعار اسبوعين الدولارات من, شرسة أعلنت اندلاع إذ هذا. وبعد الثالث أوكيناوا ما بين, الحصار الأمامية بـ عدد. ذات بقعة فمرّ إذ, أخذ كل بالحرب وسمّيت المانيا. و فصل بمباركة المقيتة, أملاً الحصار المتاخمة من عدد. بزمام أثره، التبرعات تم بعد, الجيش خصوصا كانتا ان دار. https://www.youtube.com/watch?v=JEreM0ZKY18 

Wie kann das gemacht werden?

Solutions Collecting From Web of "Fügen Sie video tag zu youtube link von content hinzu"

Sie können dies versuchen:

 $string = "Some text before the link http://www.youtube.com/?123 some text after the link"; preg_match_all('@(https?://www\.?youtube.com/.[^\s.,"\']+)@i', $string, $matches); var_dump($matches); 

In Ihrem Fall wäre etwas Ähnliches:

 preg_match_all('@(https?://www\.?youtube.com/.[^\s.,"\']+)@i', $post->post_content, $matches); foreach($matches as $match){ echo ""; }