$remark0 = array();
$remark1 = array();
$remark2 = array();
$remark0 = “SSSSS”;
$remark2 = “EEEEE”;
$remark = implode(" ",$remark0+$remark1+$remark2);
The O/P for the above code is just SSSS, it doesnt show EEEE. i.e Only the first one, $remark0 in this case. What is the problem here?
This works as expected. You are using + to join the arrays and this is the union operator, which adds one array to another but does not overwrite elements with existing keys. Both $remark0 and $remark2 have one element at index 0 - because $remark0 is before $remark2 in your union then the element at index 0 is not overwritten by the value from $remark2. If you want all values to be preserved use array_merge().
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.