How should I efficiently delete elements from a PHP array? In this case I have an array that is parsed from a JSON file. Normally I use all the elements in the array, but for AJAX crawling I only show the parts the search engine asked for:

&lt;?php $fitstyles = json_decode(file_get_contents(DATA_FILE), true); ?&gt;
…
&lt;?php
if ($base == "fits" || $base == "gallery") {
    /* For fragment handler, delete out the parts of the fits array that aren't needed. */
    $keep_fit = $fragments[1];
    $keep_style = $fragments[2];
    foreach ($fitstyles as $fit =&gt; $styles) {
        if ($fit != $keep_fit) {
            unset($fitstyles[$fit]);
            continue;
        }
        foreach ($styles as $style =&gt; $styleinfo) {
            if ($style != $keep_style) {
                unset($fitstyles[$fit][$style]);
                continue;
            }
        }
    }
} ?&gt;


Here, $fragments looks like:

(
    [0] =&gt; fits
    [1] =&gt; straight
    [2] =&gt; utility
)


and $fitstyles takes the following form:

Array
(
    [straight] =&gt; Array
        (
            [utility] =&gt; Array
                ( … )
        )
    [anotherfit] =&gt; Array
        (
            [anotherstyle] =&gt; ( … )
        )
)


The approach appears to work; however, please give me feedback as to the effectiveness, efficiency and readability of this approach.
Your code is just fine, exactly how I would do it. 

There isn't much to discuss really, it's kind of simple. It's as effective / efficient as it could be, and fairly readable.