如何使用php处理这个数组?

时间:2011-01-31 05:36:49

标签: php arrays civicrm

我正在从csv文件导入用户数据。上传后我得到了这种数组

CRF_Tester_Import_Parser_TesterData Object
(
    [_mapperKeys:protected] => Array
        (
        )

    [_contactIdIndex:private] => 
    [_newTeachers:protected] => Array
        (
        )

    [_fileName:protected] => 
    [_fileSize:protected] => 0.23
    [_seperator:protected] => ,
    [_lineCount:protected] => 5
    [_totalCount:protected] => 4
    [_validCount:protected] => 4
    [_invalidRowCount:protected] => 0
    [_maxErrorCount:protected] => 250
    [_errors:protected] => Array
        (
        )

    [_conflictCount:protected] => 0
    [_conflicts:protected] => Array
        (
        )

    [_duplicateCount:protected] => 
    [_duplicates:protected] => 
    [_warningCount:protected] => 0
    [_maxWarningCount:protected] => 25
    [_warnings:protected] => Array
        (
        )

    [_fields:protected] => 
    [_activeFields:protected] => 
    [_activeFieldCount:protected] => 1
    [_maxLinesToProcess:protected] => 100
    [_rows:protected] => Array
        (
            [0] => Array
                (
                    [0] => Contact ID,First Name,Email,Contribution Type,External Identifier,date,Total Amount
                )

            [1] => Array
                (
                    [0] => 1001,abc,abc@abc.com,aaa,active,2011-1-10,100
                )

            [2] => Array
                (
                    [0] => 1002,fff,fff@fff.com,yes+,active,2010-11-05,200
                )

            [3] => Array
                (
                    [0] => 1003,ggg,kkk@kkk.com,basic,active,2011-1-20,300
                )

        )

    [_errorFileName:protected] => 
    [_conflictFileName:protected] => 
    [_duplicateFileName:protected] => 
    [_haveColumnHeader:protected] => 
    [_contactType] => Individual
)

从这个数组中我如何处理“_rows:protected”键值?

1 个答案:

答案 0 :(得分:1)

我猜你因为会员名中的冒号而有问题,试试这样:

foreach($CRF_Tester_Import_Parser_TesterData->{'_rows:protected'} as $k=>$item)
{
  echo $item[0];
}