Roman Roman - 6 months ago 19
PHP Question

Zend Warning Assignment

Zend is telling me i have an assignment in condition line 279, I'm not sure if this will be a issue later.

// Get position of delimiters
$pos = [];
foreach ($delims as $delim) {
if ($p = strpos($this->data, $delim, min($this->index, $this->length))) {
$pos[] = $p;
}
}


this is line 279

if ($p = strpos($this->data, $delim, min($this->index, $this->length))) {

Answer

Looking at the similar question, this might work:

if (($p = strpos($this->data, $delim, min($this->index, $this->length))) != false)

Reason(from my understanding):

This will convert it as a conditional statement and eliminates chance of being an assignment. Hence, warning is resolved.