Ich habe einige Probleme mit Preg_replace und preg_match_all, um eine Youtube-URL zum Einbetten von Code zu konvertieren. Ja, ich weiß, dass dieses Thema schon im Stackoverflow angefasst hat aber nicht genau wie ich es möchte.Hyperlink Youtube zum Einbetten Code
ich die ID von einer URL bekommen, ohne html, mit, dass:
http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?
Aber ich habe das mit wie diese formatiert url:
<a href="http://www.youtube.com/watch?v=C9KAqhbIZ7o" class="comment-link">http://www.youtube.com/watch?v=C9KAqhbIZ7o</a>
Und ich will es konvertieren das alles:
<object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/C9KAqhbIZ7o?fs=1&hl=es_ES&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/C9KAqhbIZ7o?fs=1&hl=es_ES&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object>
Jemand kann etwas Magie tun und sagen Sie mir, den richtigen Ausdruck alle die uRL zu erkennen, erhalten die ID auf ce und konvertieren alle in einen Einbettungscode? Vielen Dank im Voraus!
Aktualisierung der Informationen:
Um zu helfen und macht es zu einem prägnanten ...
Ich habe dies:
<p>This is an example of comment</p><strong>Hi bold!</strong><p>Look a youtube url! <a href="http://www.youtube.com/watch?v=C9KAqhbIZ7o" class="comment-link">http://www.youtube.com/watch?v=C9KAqhbIZ7o</a></p>
Und ich will diese bekommen:
<p>This is an example of comment</p><strong>Hi bold!</strong><p>Look a youtube url! <object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/C9KAqhbIZ7o?fs=1&hl=es_ES&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/C9KAqhbIZ7o?fs=1&hl=es_ES&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
Vielen Dank für Ihre Hilfe, ich schätze es wirklich!
Wie werden Sie die "unformatiert url" bekommen? weil der href-Parameter des a-Elements schneller ist. –
Danke für Ihren Kommentar. Die URL wird automatisch formatiert, weil Wordpress sie konvertiert und ich möchte, dass sie so läuft. Und ja, ich weiß, ist schneller, aber ich möchte alle a-Element ersetzen, nicht nur die ID des Videos. – miduga