mercredi 18 mars 2015

Parse error - Comparing int values in a if statement

Currently I'm working on a function that should change the pos values (int values) of an array like this one:



$comb = array(
'A' => array('pos' => 3, 'lett' => 'C'),
'B' => array('pos' => 4, 'lett' => 'D'),
);


The function that should perform what i need is the following one:



function change($comb) {
foreach ($comb as $value) {
if($value['pos']== 1) {
$value['pos'] = 4;
} else {
$value['pos']--;
}
}
}


I can not understand why during the execution of the code, an general parse error occurs at the line of the if condition. I tried casting $value ['pos'] in int, but this does not seem to solve the problem.


Any idea?


Aucun commentaire:

Enregistrer un commentaire