What are some potential pitfalls of extending concatenation when adding array entries in PHP?
Extending concatenation when adding array entries in PHP can lead to unexpected results, as the concatenation operator (.) is used for string concatenation and not for adding elements to an array. To add entries to an array in PHP, you should use array_push() or direct assignment to a specific key.
// Incorrect way of extending concatenation to add array entries
$array = [];
$array[] = 'first' . 'second'; // This will add a single element 'firstsecond' to the array
// Correct way of adding array entries using array_push()
$array = [];
array_push($array, 'first', 'second'); // This will add two separate elements 'first' and 'second' to the array