[SOLVED] How to work with the $form->data Array

doromi 25 Oct, 2013
Hi,

when trying to collect data from two tables via two DB Multi Record Loaders I get a data array looking like that:
[CC] => Array
(
   [0] => Array
       (
           [cf_id] => 38
           [vote] => 0
           [U] => Array
           (
              [0] => Array
                 (
                    [id] => 838
                 )
            )
        )
    [1] => Array
        (
            [cf_id] => 43
            [vote] => 1
            [U] => Array
            (
               [0] => Array
                  (
                     [id] => 837
                  )
            )
        )
)


I don't care that much about the way the data look, but - how do I display them via php ?
I don't know how to get the counter into the code...
Trying this
<?php
$count = 0;
foreach($form->data['CC'] as $detail ) 
{
	echo 'ID: ' . $detail[.$count .]['U'][0][id];
	echo 'Vote: ' . $detail[vote];
	echo '<br>';
	$count = $count + 1;
}
?>

doesn't work... What has to be around the "$count" to get the counter working ?

Thanks for help...

Doris
GreyHead 25 Oct, 2013
Hi Doris,

You don't say what you need to do with the data here?

One solution might be:
<?php
foreach ( $form->data['CC'] as $detail )
{
   echo "ID: {$detail['U'][0]['id']} Vote: {$detail[vote]}<br>";
}
?>

Bob
doromi 06 Nov, 2013
Hi Bob,

thanks again for your reply !

You suggested exactly what I was looking for, and it works perfect !

Thanks for your help,

kind regards
Doris
This topic is locked and no more replies can be posted.