How can the provided PHP code snippet be optimized to avoid unnecessary array manipulation?

The provided PHP code snippet can be optimized by avoiding unnecessary array manipulation when checking if a value exists in an array. One way to solve this is by using the in_array() function, which directly checks if a value exists in an array without the need for additional array manipulation.

// Original code snippet
$myArray = ['apple', 'banana', 'orange'];
$valueToCheck = 'banana';
$isValueExists = (in_array($valueToCheck, $myArray)) ? 'Value exists' : 'Value does not exist';
echo $isValueExists;