Re: Arrays again again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem there is that you've got $a[$year] getting set a bunch of
times.  That is busted code.  $a[$year] will only contain the LAST value.

Replace that line with this one.

    $a[] = array(year=>$year, value=>$value);

OR

    $a[$i] = array(year=>$year, value=>$value);

Now $a[0][year] = 2002
Now $a[0][value] = 320

And on and on.

Peter

On 13 Nov 2002, Marco Tabini wrote:

> Perhaps I don't understand what it is you're looking for, but...
>
> $a = array();
> for ($i = 0; $i < $maxvalue; $i++)
> {
> 	$a[$year] = $value;
> }
>
> but this is almost too simple, which probably just means I didn't quite
> understand your question.
>
>
> Marco
> --
> ------------
> php|architect - The magazine for PHP Professionals
> The monthly worldwide magazine dedicated to PHP programmers
>
> Come visit us at http://www.phparch.com!
>
> On Wed, 2002-11-13 at 19:28, Martin Allan Jensen wrote:
> > Sorry fellers....
> >
> > Allready figured it out....sorry....now i see that the question was foolish....
> >
> > Anyway now i need help with something else...
> >
> > I now have some values:
> > 320  -  250  -  290  -  100
> > And years that fits to them:
> > 2002 - 2003 - 2004 - 2005
> >
> > How can i put these dynamic values in a array..... be carefull cause i need the array to be filled active in a loop, so i CAN only define ONE year, and ONE value in each LOOP!
> >
> > THANKS!!!
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux