Is there a way to shorten a set of conditionals like this?
In short, the CSV parser is using the wrong data types. Whenever you have contiguous variable names, it screams "use an array!" If you at all, possibly can, use an array. That allows you to operate on it much, much more naturally, it's more flexible, and it's way less prone to human error.



If you used an array, this would be much, much simpler:

foreach ($this-&gt;sl as $k =&gt; $sl) {
    $this-&gt;sl = ($sl === null) ? "0" : $sl;
}




Since you seemingly can't use an array, your best bet is probably to either process it into an array, or use some nasty variable-variable hackiness to pretend it's an array.

$sl = array();
for ($i = 1; isset($this-&gt;{'sl' . $i}; ++$i) {
    $sl[] = $this-&gt;{'sl' . $i};
}




Or if (for some reason) you don't want to use an array:

for ($i = 1; isset($this-&gt;{'sl' . $i}; ++$i) {
    $this-&gt;{'sl' . $i} = ($this-&gt;{'sl' . $i} === null) ? "0" : $this-&gt;{'sl' . $i};
}