title: How do I call this function in CodeIgniter controller?
body: <p>I've got this code, but I'm not sure I make it work:</p>
  
  <pre><code>/**
   * Function: youtube data grabber
   *
   * @description :
   * @param  $ : video code, url type (embed/url)
   * @return : data array
   * @author : Mamun.
   * @last -modified-by: Mamun.
   */
  
  if (! function_exists('youtube_data_grabber'))
          {
  
                  function youtube_data_grabber($video_code, $link_type = "embed")
                  {
                          if ($video_code != '')
                          {
                              if ($link_type == "embed")
                              {
                                  $splited_data = explode("=",$video_code);
                                  $video_unique_code = substr(strrchr($splited_data[4],"/"),1,-strlen(strrchr($splited_data[4],"&amp;")));
  
                              }
                              else if ($link_type == "url")
                              {
                                  $splited_data = explode("=",$video_code);
                                  $video_unique_code = substr($splited_data[1],0,-strlen(strrchr($splited_data[1],"&amp;")));
                              }
                              else
                              {
                                  return;
                              }
  
                                  // set feed URL
                                  $feedURL = 'http://gdata.youtube.com/feeds/api/videos/'.$video_unique_code;
  
                                  // read feed into SimpleXML object
                                  $sxml = simplexml_load_file($feedURL);
  
                              return $sxml;
                          }
  
                  }
          } // End Youtube Function
  </code></pre>
  
  <p>I'm not sure how to activate it is what I'm trying to say. I placed it in the controller and it's within a function for one of my pages. I don't have any syntax errors. I just don't know how to wake it up and make it work. I thought I could just put <code>youtube_data_grabber('http://www.youtube.com/watch?v=LAcrFym10ZI', 'url');</code> but that didn't work.</p>
  
  <p>I got the code from <a href="http://sumonbd.wordpress.com/2009/12/31/youtube-video-grabbing-using-zend-gdata-with-codeigniter/" rel="nofollow noreferrer">this blog</a>, and I have the zend functionality working. I tested it earlier and had no errors. I'm just having trouble with this youtube part.</p>
  
  <p>Any ideas?</p>