Php Dynamically Embed YouTube Videos -


my page accepts text in text area no chars limit. want display youtube video in place of "youtubeurl" or direct embed code of youtube if text data contains of above way.

example: if user enters following text text area :

"here video embed code: < iframe width="420" height="315" src="https://www.youtube.com/embed/7m-jsjlb20y" frameborder="0" allowfullscreen>< /iframe > , here video url: https://www.youtube.com/watch?v=7m-jsjlb20y"

so post data show in page :

here video embed code: "display youtube video here" , here video url: "display youtube video here"

in short want code php page accepts both way of youtube video embedding , find text data process it. great if can give me idea works both way.

i don't understand question, maybe regexp can want. example, imagine have text area in var $l_smycode, can extract embed code :

preg_match( '/.*(\<iframe.*\<\/iframe\>).*/i', $l_smycode, $l_amatch ); 

and url :

preg_match( '/.*(https?.*youtube.*watch?v=.*) .*/i', $l_smycode, $l_amatch ); 

you match pattern in $l_amatch[1] , can replace str_replace, or in 1 regexp (you can find code on internet easily). hope you.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -