Here's how I load the array:
Code: Select all
<?php
unset($_SESSIONї'names']);
// make sure nothing left over from previous login during this session
$r = "";
$f = @fopen("files/acode.dat", "r"); // open names/codes file
if ($f != FALSE)
{ $a = @fread($f, filesize("files/acode.dat"));
fclose($f);
$r = trim($a); // trim any excess
$adata = explode("|", $r); // array of names
for ($i = 0; $i < count($adata); $i++)
{ $_SESSIONї'namesї$i]'] = $adataї$i];
}
}
?>During the session I add to the array as follows:
Code: Select all
<?php
$txt1 = $_POSTї'NewNam'];
if (strlen($txt1) == 4)
{ $_SESSIONї'namesї]'] = $txt1;
}
// it was not added, so I tried
$txt1 = $_POSTї'NewNam'];
if (strlen($txt1) == 4)
{ $i = 0;
while(isset($_SESSIONї'namesї$i]']))
$i++;
$_SESSIONї'namesї$i]'] = $txt1;
}
// but it timed out on the "while" line
?>