Page 1 of 1

Need to display values from multiple array

Posted: Wed Jun 26, 2002 10:58 am
by cathari
Hi!

How do you display the values coming from a multiple array? The problem is when i get to display the values there is another blank values coming in. Which I didn't input it in the first place. Is there any other way to do it?

Code: Select all

$count = 0;
	
do {
echo "<TR><TD>$name&#1111;$count]</TD>\n";
$CheckEmpty = "$name&#1111;$count]";
$count = $count+1;
&#125; while ($CheckEmpty!="");

Posted: Wed Jun 26, 2002 12:14 pm
by kaizix
well, using a do while loop, you'll get atleast one empty result becuase it performs the do before it check against the while which means it'll do stuff atleast once even if the while check is false...you could change it around to

Code: Select all

$count = 0; 

while ($CheckEmpty != "")
&#123;
echo "<TR><TD>$name&#1111;$count]</TD>\n";
$CheckEmpty = $name&#1111;$count];
$count = $count+1;
&#125;
also, you don't need "" around a variable to set another variable to the same value. (i'm not positive but that might actually mess it up).

Posted: Wed Jun 26, 2002 12:37 pm
by cathari
I tried doing it but it still wont work, now nothing show up on my screen. :?

Posted: Wed Jun 26, 2002 1:01 pm
by kaizix
my bad, that's because $CheckEmpty isn't set before it starts so it's empty so it doesn't go through the loop. try it with

Code: Select all

$count = 0; 
$CheckEmpty = $name&#1111;$count];
while ($CheckEmpty != "") 
&#123; 
echo "<TR><TD>$name&#1111;$count]</TD>\n"; 
$CheckEmpty = $name&#1111;$count]; 
$count = $count+1; 
&#125;
which sets CheckEmpty before the loop starts.

Posted: Thu Jun 27, 2002 1:39 am
by twigletmac
If you just want to look at the contents of an array you can do:

Code: Select all

echo '<pre>';
print_r($array);
echo '</pre>';
Mac