samedi 7 janvier 2017

Notice: Undefined offset: 27 in Test.php on line 40

I wrote something like this in JS but now i want it in php and i have this problem, can you help me guys?

server Notice: Undefined offset: 27 in Test.php on line 35

line 35 is: array_push($pole2, $pole1[$ran]);

$pole1 = array();
$pole2 = array();

for ($i = 0; $i < 50; $i++) {
    array_push($pole1, $i + 1);
}
for ($i = 0; $i < 25; $i++) {
    $ran = floor(rand(1, 50));
    // echo $ran . " ";
    array_push($pole2, $pole1[$ran]);
    array_splice($pole1, 1);
}

I tried use this but it doesnt work:

if (!isset($pole2[$ran])) {
    $pole2[$ran] = 0;
} 




Aucun commentaire:

Enregistrer un commentaire