Excluding all elements but one
<p>I have an array of things: <code>$arr = array('Apple', 'Pear', 'Pineapple');</code></p>

<p>I want to exclude everything apart from, say, 'Apple' in the array. I had a look at using <a href="http://php.net/manual/en/function.array-diff.php" rel="nofollow noreferrer">array_diff</a>, however I don't know how I would apply using that in my situation.</p>

<p>Doing <code>array_diff($arr, array('Apple'));</code> obviously excludes 'Apple' from the list.</p>

<p>Thanks for the help!</p>

<p><strong>EDIT:</strong> Since more details are required, I have to process data from an API I'm using which takes an exclusion list to simplify the JSON response. Therefore I'm using the array containing possible options to exclude.</p>