Level 67
$car_brands[1][] = 'Audi S3';
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I need best way to "add values" at specific key in array. For example:
$car_brands = [1 => ["Audi Quatro", " Audi R8", "Audi A4"], 2 => ["BMW M3", "BMW M4"]];
$car_brands[1] = "Audi S3";
This code will replace all values at key "1"with "Audi S3". Im trying to add "Audi S3" value in to the first member of $car_brands, but at the end of the array (after "Audi A4").
$car_brands[1][] = 'Audi S3';
Please or to participate in this conversation.