usort returns undefined index
<p>I have a multi dimensional array called "soldier":</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [name] =&gt; Saiga 20k Semi
            [target] =&gt; 100
            [star] =&gt; gold
        )

[1] =&gt; Array
    (
        [name] =&gt; SVU Snaiperskaya Short
        [target] =&gt; 85
        [star] =&gt; gold
    )

[2] =&gt; Array
    (
        [name] =&gt; Type 88 Sniper
        [target] =&gt; 56
        [star] =&gt; gold
    )
</code></pre>

<p>I am trying to sort the array by the "target" value. I am using:</p>

<pre><code>usort($soldier,'compare_target');

function compare_target($x,$y)
{
    if($x['target'] == $y['target'])
    {
        return 0;
    }
    elseif($x['target'] &lt; $y['target'])
    {
        return 1;
    }
    else
    {
        return -1;
    }
}
</code></pre>

<p>But PHP is throwing the following error: "Undefined index: target" for the 2 lines inside the function, any ideas?</p>
