Simple class to retrieve an ID using a URL of the Youtube


/ Published in: PHP
Save to your folder(s)

Simple class to retrieve an ID using a URL of the Youtube


Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3.  
  4. Simple Class capture ID Youtube
  5. Leandro Peres - 04/01/0212
  6.  
  7. */
  8.  
  9. class Youtube {
  10. private $url;
  11.  
  12. function PegaID ($url = null) {
  13. $url = substr($url, strpos($url, "v="));
  14. $this->url = str_replace("v=", "", $url);
  15. echo $this->url;
  16. }
  17. }
  18.  
  19. $Youtube = new Youtube();
  20. $ID = $Youtube->PegaID("http://www.youtube.com/watch?v=RmeXANd7c8I");
  21. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.