> -----Original Message-----
> From: John Wulff [mailto:[EMAIL PROTECTED]
> Sent: 30 June 2003 21:40
>
> I want to write a function that manipulates each piece of
> data in an array
> (except for the first). Right now I'm using list as follows from this
> array:
>
> $cdata = array(
> array("Apr-03",12747.17,23486.55,319062.24,257828.73,0.00),
> array("Sep-02",12379.46,10246.92,482295.71,618131.35,14.99)
> );
>
> foreach($cdata as $key=>$value)
> {
> list($month, $a, $b, $c, $d, $e) = $value;
> }
>
> I'd like to not have to change any of my code for an
> undertermined number of
> $a, $b, etc., etc. How do I do this?
Well, two possibilities off the top of my head:
foreach($cdata as $key=>$value)
{
$n = 0;
foreach ($value as $inner_key=>$inner_value)
{
if ($n++)
{
// do stuff with $inner_key and $inner_value
}
}
}
Or:
foreach($cdata as $key=>$value)
{
$date_element = array_shift($value);
// $date_element now contains original first element of $value
// $value now contains remaining elements
// do whatever you want with them here
}
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php