I am wondering if I can set a variable to infinity, and if not what the best way to achieve my problem is. Take my function below:
public function seekValue($value, $column = null, $limit = null) {
$this->connect('rb');
$results = array();
while (!feof($this->_pointer)) {
$data = explode($this->_config->delimiter(), fgets($this->_pointer, 1024));
if(!is_null($column)) {
if ($data[$this->_config->columns($column, "string")->index()] == $value)
array_push($results, $this->formatRow($data));
} else {
if (in_array($value, $data))
array_push($results, $this->formatRow($data));
}
}
$this->disconnect();
switch (count($results)) {
case 0;
return false;
case 1;
return $results[0];
default;
return $results;
}
}
I set $limit = null in the function parameter list, however I later want to use $limit in my while loop like so while (!feof($this->_pointer) && count($results) < $limit) incase the user decides to pass an integer to it.
If this was the case I could do this:
if (!is_int($limit)) {
$limit = infinity;
}
To say that if $limit is not set run infinite times.
I hope this makes sense.
Why don’t you just adapt the condition: