CJabber201
CJabber201

Reputation: 87

Array row is overwriting another rows

I wrote this array:

$params = array(
    'credentials' => array(
        'ApiKey' => $ApiKey,
        'DatabaseId' => $DatabaseId,
        'UserId' => $userId,
    ),
    'parentRelationId' => $parentRelationId,
    'relationEntityTypeId' => $relationEntityTypeId,
    'relationFieldValues' => array(
        'PvFieldValueData' => array(
            'Id' => 1234,
            'Value' => 'Test value',
        ),
        'PvFieldValueData' => array(
            'Id' => 23456,
            'Value' => 'Test 2 value',
        ),
    ),
    'relationshipEntityTypeId' => 1234,
);

When printing the array it gives me this:

Array
(
    [credentials] => Array
        (
            [ApiKey] => *APIKEY*
            [DatabaseId] => *DATABASEID*
            [UserId] => *USERID*
        )

    [parentRelationId] => 
    [relationEntityTypeId] => 
    [relationFieldValues] => Array
        (
            [PvFieldValueData] => Array
                (
                    [Id] => 23456
                    [Value] => Test 2 value
                )

        )

    [relationshipEntityTypeId] => 1234
)

Where is the row with id 1234 and value Test value ? I think it is overriding because of the same array key but is it possible to have both the rows with the same key name?

Upvotes: 1

Views: 41

Answers (1)

foder
foder

Reputation: 113

You can't have both rows with the same key. But is this really necessary here to have a key name? Why don't you use this :

'relationFieldValues' => array(
        array(
            'Id' => 1234,
            'Value' => 'Test value',
        ),
        array(
            'Id' => 23456,
            'Value' => 'Test 2 value',
        ),
    ),

Upvotes: 1

Related Questions