What are the potential pitfalls of storing conversion factors in an array in PHP, and how can they be avoided?

Storing conversion factors in an array in PHP can lead to potential pitfalls such as the risk of accidentally overwriting or modifying the values in the array, making it difficult to maintain and update the conversion factors. To avoid this issue, it is recommended to use constants or a configuration file to store the conversion factors, ensuring that they remain unchanged during the execution of the script.

// Define conversion factors as constants
define('INCHES_TO_CM', 2.54);
define('CM_TO_INCHES', 0.393701);

// Example of using the conversion factors
$inches = 10;
$cm = $inches * INCHES_TO_CM;
echo "$inches inches is equal to $cm cm";