0

began programming in PHP this week so total beginner here. The code sample below is not complete but it gives you an idea of the issue. If I keep only 2 properties in my class I am able to convert and display the JSON structure from my array, HOWEVER as I add more properties in the class nothing is returned/displayed/converted. Why is that? Thanks NOte: I tried a few options from http://php.net/manual/en/json.constants.php

<?php
class myObject
{
    public $Channel;
    public $Program;
    public $Episode;
    public $Start;        
    public $End;
    public $TZ;
}

$myBlackouts = array();
$row = 1;

if (($handle = fopen($file_name, 'r')) !== FALSE)
{
  while (($data = fgetcsv($handle, 1000, ',')) !== FALSE)
  {    
      //feed variables here
      $myBlackout             = new myObject;
      $myBlackout->Channel    = $Channel;
      $myBlackout->Program    = $Program;
      $myBlackout->Episode    = $Episode;
      $myBlackout->Start      = $StartEpoch;
      $myBlackout->End        = $EndEpoch;
      $myBlackout->TZ         = $TZ;                       
      $myBlackouts[]          = $myBlackout;    
      $row++;
  }
  fclose($handle);
}

echo 'Array lenght: '.count($myBlackouts)."\n"; //331 elements inside array
$myJSON = json_encode($myBlackouts);    //convert array to JSON
echo $myJSON;               // it will not display anything if I increase the number of properties in my class above
?>

Thanks

Max
  • 1,289
  • 3
  • 26
  • 50

1 Answers1

0

iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($input)); was the solution for my case.

Max
  • 1,289
  • 3
  • 26
  • 50