array index ordering



Lets say we have an array:

$array[]='apples';
$array[]='orange';
$array[]='lemon';

echo $array[1]; // orange


Now, lets say we want to insert "grape", between apples and orange. How do we do that?

I have some memory of seeing a php shortcut to do this, but I can't find it now.

Also, I see there are a number of custom php functions for sorting (kudos on some of these). Is there a way to write your own sorting function?

Jeff
.



Relevant Pages

  • Re: array index ordering
    ... Now, lets say we want to insert "grape", between apples and orange. ... You just add it like above and then sort the array. ... I see there are a number of custom php functions for sorting ... Is there a way to write your own sorting function? ...
    (comp.lang.php)
  • Re: array index ordering
    ... Now, lets say we want to insert "grape", between apples and orange. ... I have some memory of seeing a php shortcut to do this, ... Is there a way to write your own sorting function? ...
    (comp.lang.php)