mardi 24 mars 2015

PHP foreach if doesn't work as expected

I have this code:



$update = 1;
$insert = 0;

$myArray = array(0,1);
foreach ($myArray as $cicle){

echo "update: ". $update."<br>";
echo "insert: ". $insert."<br><br>";

if ($insert = 1) { echo "I write because update is 1.<br>"; continue; }

if ($insert = 0 and $update = 0) { continue; }


for ($i = 1; $i <= 3; $i++){

echo("Hi!<br>");

}

echo "<br>";

$update = 0;
$insert = 1;

}


but it doesn't work as expected. I want the first three "Hi!" and then nothing because I set insert to 1.


Nothing works with this code. Why?


Aucun commentaire:

Enregistrer un commentaire