phpvar-dump

PHP: var_dump output is not full


There is php code:

<?php
$lines = array();
$handle = @fopen("./1.csv", "r");
if ($handle) {
    while (($buffer = fgets($handle, 4096)) !== false) {
        $lines[] = $buffer;
        foreach ($lines as $line) {
                 getNo($line);
        }
    }
    fclose($handle);
}
function getNo($line) {
        $allowedSources = array(
        '_10' => 1,
        '_20' => 1,
        '_60' => 1
        );

        $providerList = explode(",",$line);
        $sourceList = array();
        foreach ($providerList as $providerInfo) {
                        $providerAndSource = explode("_",$providerInfo);
                        $provider = $providerAndSource[0];
                        $source = "_" . $providerAndSource[1];
                if ( (array_key_exists($source,$allowedSources)) )

                {
                        $sourceList[] =  $source;
                }
        }
        var_dump($sourceList);
}
?>

1.csv

1       4_10,5_20,6_60

And output is:

array(2) {
  [0]=>
  string(3) "_10"
  [1]=>
  string(3) "_20"
}

Why "_60" is not in output?


Solution

  • I just added

    trim($line);
    

    after

    foreach ($lines as $line) {
    

    This resolved my issue