Skip to content

Commit d602d75

Browse files
author
Craig Manley
committed
Ignore null option values.
1 parent 681ac8b commit d602d75

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CSVReader.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Craig Manley
1414
* @copyright Copyright © 2010, Craig Manley (www.craigmanley.com)
1515
* @license http://www.opensource.org/licenses/mit-license.php Licensed under MIT
16-
* @version $Id: CSVReader.php,v 1.17 2014/06/13 22:27:39 cmanley Exp $
16+
* @version $Id: CSVReader.php,v 1.18 2016/02/15 00:57:54 cmanley Exp $
1717
* @package cmanley
1818
*/
1919

@@ -55,7 +55,7 @@ class CSVReaderException extends Exception {}
5555
* // Show fieldnames from 1st row:
5656
* print_r($reader->fieldNames());
5757
*
58-
* // Iterate over all the rows using foreach. CVSReader behaves as an array.
58+
* // Iterate over all the rows using foreach. CSVReader behaves as an array.
5959
* foreach($reader as $row) { // $row is a CSVReaderRow object
6060
* print 'Price: ' . $row->get('Price') . "\n";
6161
* print 'Name: ' . $row['Name'] . "\n"; // $row also supports array access
@@ -149,8 +149,11 @@ function __construct($file, array $options = null) {
149149
$opt_include_fields = null;
150150
if ($options) {
151151
foreach ($options as $key => $value) {
152+
if (is_null($value)) {
153+
continue;
154+
}
152155
if (in_array($key, array('debug', 'skip_empty_lines'))) {
153-
if (!(is_null($value) || is_bool($value) || is_int($value))) {
156+
if (!(is_bool($value) || is_int($value))) {
154157
throw new \InvalidArgumentException("The '$key' option must be a boolean");
155158
}
156159
$this->$key = $value;

0 commit comments

Comments
 (0)