title: Warning: explode() expects parameter 2 to be string
body: <p>I have got a problem with my PHP, I'm trying to convert the hours into format, example: I have the time of 9:00 PM and I'm converting them to format 20140501210000.</p>
  
  <p>When I try to convert the time into format, I'm getting the warning which it expects parameter 2 to be string. The error are jumping on this line: <code>$ex = explode(" ",$string);</code></p>
  
  <p>Here is the input for the time:</p>
  
  <pre><code>9:00 PM 9:30 PM 9:00 PM 9:00 PM 9:00 PM 9:00 PM 9:30 PM
  </code></pre>
  
  <p>Here is the errors I have got:</p>
  
  <pre><code>Warning: explode() expects parameter 2 to be string, object given in /home/myusername/public_html/work_on_this.php on line 8
  
  Warning: explode() expects parameter 2 to be string, object given in /home/myusername/public_html/work_on_this.php on line 8
  
  Warning: strtotime() expects parameter 1 to be string, object given in /home/myusername/public_html/work_on_this.php on line 78
  19700101010000
  
  
  Warning: explode() expects parameter 2 to be string, object given in /home/myusername/public_html/work_on_this.php on line 8
  
  Warning: explode() expects parameter 2 to be string, object given in /home/myusername/public_html/work_on_this.php on line 8
  
  Warning: strtotime() expects parameter 1 to be string, object given in /home/myusername/public_html/work_on_this.php on line 78
  19700101010000
  </code></pre>
  
  <p>Here is the PHP:</p>
  
  <pre><code>&lt;?php
  ini_set('max_execution_time', 300);
  $errmsg_arr = array();
  $errflag = false;
  
  function getState($string)
  {
    $ex = explode(" ",$string);
    return $ex[1];
  }
  
  $xml .= '&lt;?xml version="1.0" encoding="UTF-8" ?&gt;';
  $xml .= '
  &lt;tv generator-info-name="www.mysite.com/xmltv"&gt;';
  
  $baseUrl = file_get_contents('http://www.mysite.com/get-listing.php');
  
  $domdoc = new DOMDocument();
  $domdoc-&gt;strictErrorChecking = false;
  $domdoc-&gt;recover=true;
  //@$domdoc-&gt;loadHTMLFile($baseUrl);
  @$domdoc-&gt;loadHTML($baseUrl);
  $links = $domdoc-&gt;getElementsByTagName('a');
  $i = 0;
  $count = 0;
  
  $data = array();
  foreach($links as $link)
  {  
    //echo $domdoc-&gt;saveXML($link);
    if($link-&gt;getAttribute('href'))
    {
       if(!$link-&gt;hasAttribute('id') || $link-&gt;getAttribute('id')!='streams')
       {
         $url = str_replace("rtmp://", "", $link-&gt;getAttribute('href'));
         $url = str_replace(" ", "%20", $link-&gt;getAttribute('href'));
         //echo $url;
         //echo "&lt;br&gt;";
         $sdoc = new DOMDocument();
         $sdoc-&gt;strictErrorChecking = false;
         $sdoc-&gt;recover=true;
         @$sdoc-&gt;loadHTMLFile($url);
         $time1_span = $sdoc-&gt;getElementById('time1');       
         //$spans = $sdoc-&gt;getElementsByTagName('time1');
         $query = parse_url($url)['query'];
         $channel_split = explode("&amp;", $query)[0];
         $channel = urldecode(explode("=",$channel_split)[1]);
         $id_split = explode("&amp;", $query)[1];
         $my_id = urldecode(explode("=",$id_split)[1]);
         $xpath = new DOMXpath($sdoc);
         $time1 = $xpath-&gt;query("*/span[@id='time1']");
         //$time2 = $xpath-&gt;query("*/span[@id='time2']");
         //$time3 = $xpath-&gt;query("*/span[@id='time3']");
         //$time4 = $xpath-&gt;query("*/span[@id='time4']");
  
         $array = array(
           $time1,
         );
  
         // Save the output format
         $DATE_FORMAT_STRING = "YmdHis";
  
         // GET the current STAGE
         $current_state = getState($array[0]);
         $offset = 0;
         $flag = 0;
  
         foreach($array as $time)
         {
           // Get the item state.  
           $this_state = getState($time);
  
           // check if we past a day? 
           if($current_state == "PM" &amp;&amp; $this_state == "AM")
           {
             $offset++;
           }
           $this_unix = strtotime($time) + (60 * 60 * 24 * $offset);
           $values[] = date($DATE_FORMAT_STRING, $this_unix);
           //echo date($DATE_FORMAT_STRING, $this_unix);
           echo $values[0];
           echo "&lt;br&gt;&lt;/br&gt;";
           $current_state = $this_state;
           $count++;
         }
       }
    }
  }
  ?&gt;
  </code></pre>
  
  <p>Do you know why I'm getting the warning errors and do you know how to fix it? </p>