Need to display values from multiple array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cathari
Forum Newbie
Posts: 11
Joined: Mon May 13, 2002 9:51 pm

Need to display values from multiple array

Post 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!="");
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post 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).
cathari
Forum Newbie
Posts: 11
Joined: Mon May 13, 2002 9:51 pm

Post by cathari »

I tried doing it but it still wont work, now nothing show up on my screen. :?
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply