What is the difference between accessing properties in an array and an object in PHP?

When accessing properties in an array in PHP, you use square brackets with the key inside to access the value. On the other hand, when accessing properties in an object in PHP, you use the arrow operator (->) followed by the property name to access the value.

// Accessing properties in an array
$array = ['key' => 'value'];
echo $array['key']; // Outputs: value

// Accessing properties in an object
$object = (object)['key' => 'value'];
echo $object->key; // Outputs: value