Sort an array of sentences alphabetically, ignoring the first word if it equals 'the' (case insensitive) function order_ignore_the($a, $b){
     // orders sentences ascending alphabetically, ignoring the  work &quot;the&quot;
     $args = func_get_args();
     foreach($args as $k=&gt;$v){
          
          $sort = explode(&quot; &quot;,$v);
          $args[$k] = (strtolower($sort[0]) == &quot;the&quot; ? $sort[1] : $sort[0]);
     }
     
    return strcmp($args[0], $args[1]);
}

usort($array_of_sentences,'order_ignore_the');
With some testing, it should look like the below

function order_ignore_the($a, $b) {
    return strcasecmp(
        strcasecmp(substr($a, 0, 4), "the ") != 0 ? $a : substr($a, 4),
        strcasecmp(substr($b, 0, 4), "the ") != 0 ? $b : substr($b, 4)
    );
}


Main differences being:


Widening the search for "the" to include the space after. Otherwise, you're matching on things like "theater", etc.
The last substr should likewise have start position 4. Otherwise, you're comparing on the space after "the".
You'll want the main comparison to ignore capitalization, too.