Imploded array elements still being returned as "Array&
Posted: Mon Dec 12, 2005 9:30 pm
In the code below, I explode a string, then explode some of its array elements. I manipulate them, then I implode the array elements, and implode the original array, thus getting the entire string with some manipulated elements back, while still being able to parse the information at a later date.
However, many times the elements of the main array simply get returned as the word "Array", even though they are always imploded into a string. I can't figure out why.
Here's the code:
Can anyone help me, please?
However, many times the elements of the main array simply get returned as the word "Array", even though they are always imploded into a string. I can't figure out why.
Here's the code:
Code: Select all
<?php
if ($ouid<1 || $ouid=="") {
exit("<b><u><center>Please log in to the Twisted Designs Graphics forum and make sure 'Remember Me' is checked YES before attempting to adjust a member's grade.<br><br><a href='JavaScript:window.close()'>Back to Profile (Close This Window)</a></b></u></center>");
}
$all="";
if (file_exists("grades.txt")) { $all=file_get_contents("grades.txt"); }
$all=explode("\r\n",$all);
$stop=0;
$newgrade=$grade;
for ($i=0; $i<count($all); $i++) {
if ($all[$i]=="") { unset($all[$i]); continue; }
$all[$i]=explode("|",$all[$i]);
if ($all[$i][0]==$uid) { $all[$i][1]=(double)$grade+(double)$all[$i][1]; $all[$i][2]=(double)1+(double)$all[$i][2]; $newgrade=$all[$i][1]/$all[$i][2]; $stop=1; break; }
$all[$i]=implode("|",$all[$i]);
}
if ($stop==0) {
$all[$i+1]=$uid."|".$grade."|1";
}
for ($i=0; $i<count($all); $i++) { if ($all[$i]=="") { unset($all[$i]); } }
$all=implode("\r\n",$all);
$f=fopen("grades.txt","w");
fwrite($f,$all);
fclose($f);
echo "<b><u><center>Thank You. Your Grade Has Been Entered And Averaged Into The Member's Total Grade. His/Her Grade Is Now ".$newgrade."%.<br><br><a href='JavaScript:window.close()'>Back to Profile (Close This Window)</a></b></u></center>";
?>