p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   PHP How-To (http://p2p.wrox.com/forumdisplay.php?f=98)
-   -   Array woes (http://p2p.wrox.com/showthread.php?t=36625)

hillbilly geek December 31st, 2005 12:50 AM

Array woes
 
I'm a newbie, working with php4.

I'm passing arrays from a form: a series of variables with the same
name like: Child[] and Age[]

I'm capturing them with:
        $Child[] = array($_POST['Child[]']);
        $Age[] = array($_POST['Age[]']) ;

then, I'm using:

 <?php
$Count=0 ;
echo "<h3>Registering $numChildren Children</h3>" ;
do
{
                echo "<p>$Child[$Count], Age $Age[$Count], $Gender[$Count]<p>" ;
                echo "<p>Info: " . $Info[$Count] . "<p>" ;
                $CheckEmpty = "$Child[$Count]" ;
                $Count="$Count+1" ;

} while ($CheckEmpty!="") ;

if ($Count==1) echo "Not Applicable" ;
?>
However, I get this result on the page: (for 2 entries):

Array, Age Array, Array
Info: Array

, Age ,
Info:

In other words: the first set of values are replaced with "Array"

And the second set of values don't show up.
I also tried it with three sets, and the third set didn't register at all
Help? Thanks!

---
Descartes goes into a restaurant and orders a cup of coffee. He sits for a while, drinking his coffee and reading the paper. A little while later, the waitress comes by and asks him if he would like another cup. He says "I think not" and disappears...

anshul December 31st, 2005 03:21 PM

Many times, we need to reset() arrays before using them. I'm though, not sure if it solves your problem ..

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances

Mantis January 8th, 2006 12:28 AM

I'm not too sure how you "POST" an array to be honnest??
Its 4am here so i'm going to make an observation cause I don't want to create an array right now ;)
Did you try:
<?php
$Child[]=$_POST['Child[]'];


All times are GMT -4. The time now is 09:16 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.