What is the common mistake made when using arrays in PHP to store information like article numbers and quantities for a webshop?

The common mistake is not using associative arrays to store information like article numbers and quantities in a webshop. Using indexed arrays can lead to confusion and errors when trying to retrieve specific information later on. To solve this issue, use associative arrays where the article number is the key and the quantity is the value.

// Incorrect way using indexed arrays
$articles = [123, 456, 789];
$quantities = [2, 1, 3];

// Correct way using associative arrays
$cart = [
    123 => 2,
    456 => 1,
    789 => 3
];