PHP explode(),返回分隔符?

I'm not sure why but the explode function doesn't seem to be working for me.

I have a string which contains one or more sets of comma-seperated values. These sets are delimied by starting / ending square brackets.

After stripping off the ending "[" and "]", I thought it would be simple to then use the explode function to get the results seperated by "][". Instead, I get something weird.

$rawInserts = '[1,2,3,4,5][2,3,4,5,6][3,4,5,6,7]';
$the_inserts = substr($rawInserts,1,strlen($rawInserts)-2);
echo "$the_inserts 
"; //returns "1,2,3,4,5][2,3,4,5,6][3,4,5,6,7"
$inserts = explode($the_inserts , "][");
echo print_r($inserts)."
"; // returns one item array containing "][";

why is it returning "]["? (FYI, I tried this exact example and it fails).

Thanks in advance.

array explode ( string $delimiter , string $string [, int $limit ] )

Delimiter first, string second.

Switch the parameters. It's delimiter first and string as second parameter:

$inserts = explode('][', $the_inserts);

it should be $inserts = explode("][",$the_inserts );

I myself cannot remember the parameters for every function, so just go to the php.net website and search for the explode function.