I am trying to produce a function that calls something from the Wordpress custom area ("_videourl" for any YouTube video URL) after which uses PHP trim to work lower to simply the YouTube video ID. I discovered a javascript function that decreases Web addresses to simply the ID however i have no clue how I'd have the ability to translate that into php (function below):

     function youtubeIDextract(url) 
     var youtube_id; 
     youtube_id = url.replace(/^[^v]+v.(.{11}).*/,"$1"); 
     return youtube_id; 

This PHP function could be used within the loop and so i think I would need to use variables, but I am really only a noob and so i have no clue how to proceed. Can anybody help by discussing their coding knowledge of helping me produce a PHP function?

Presuming the regex is correct, you could utilize [cde]


You may even want to consider [cde] or [cde] as options.