使用php访问数组元素中字段的正确方法是什么?

I'm getting a few rows from the DB with an ajax call in PHP and I save the result to an array with javascript.
Then I make some changes in the data and wish to update the DB.
So I use another ajax call for that but I can't manage to access the fields inside the rows correctly.
When I try this I get nothing:

echo $bArray[$i].branchId;

When I try this:

echo json_encode($bArray[$i].branchId);

I get ArraybranchId instead of the field value.

What's the correct way to access the field with php?

Try either for array:

$bArray[$i]['branchId']

or for object:

$bArray[$i]->branchId

depending which type $bArray[$i] is (array or object). You have not written in your question, so I showed both ways.

I take it branchId is the name of the field, and you want the value for that field?

If so, it's:

echo $bArray['branchId']; or echo $bArray[$i]['branchId']

Edit: Also, you'll need to make sure you're using mysql_fetch_assoc not mysql_fetch_array!