[FX.php List] Summary of Records
Gjermund Gusland Thorsen
ggt667 at gmail.com
Mon Dec 8 08:48:47 MST 2008
I am under the impression that usually you will have to traverse the
array of returned records prior to your formatting of the output, so
the simple way to resolve this issue is to make a summary array:
foreach( $r['data'] as $k => $v ) {
$sumarryOfField[$v['team'][0]] = $sumarryOfField[$v['team'][0]] +
$v['Field'][0];
}
or
foreach( $r['data'] as $k => $v ) {
$fieldsToSum[$v['team'][0]][] = $v['Field'][0];
}
but then you will have to sum the array after, however you could do
weighted values to check for validity in values.
ggt
2008/12/8 Anders Monsen <andersm at alamark.com>:
> How about array_unique?
>
> $theList = array('Team1','Team1','Team2','Team3','Team1','Team2' );
> $uniqueList = array_unique($theList);
> sort($uniqueLists);
>
> Anders
>
> On Dec 8, 2008, at 9:35 AM, Steve Winter wrote:
>
>> Hi William,
>>
>> You could go with something like this;
>>
>> $uniqueList = array()
>>
>> foreach($teamList as $team) {
>> if(!in_array($team, $uniqueList) {
>> $uniqueList[] = $team;
>> }
>> }
>>
>> Then $uniqueArray will have only one entry for each $team. You may also
>> then want to do a sort on that array prior to output in case the data that
>> it received was
>>
>> Team3
>> Team1
>> Team3
>> Team2
>>
>> Cheers
>> Steve
>>
>>
>>
>>
>> On 8 Dec 2008, at 15:05, william.downs wrote:
>>
>>>
>>> Hi there List,
>>>
>>> If an array was to return more than one record, and a value was repeated,
>>> how do I strip out the individual values ?
>>>
>>> Example :
>>>
>>> If the returned values were
>>>
>>> Team1
>>> Team2
>>> Team1
>>> Team3
>>> Team1
>>>
>>> I would ONLY want to see
>>> Team1
>>> Team2
>>> Team3
>>>
>>> In Filemaker, I could create a value list, or a sub-summary list, and
>>> this would give me the individual records.
>>>
>>>
>>> Kindest Regards
>>>
>>> William
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
More information about the FX.php_List
mailing list