Just a note... you have the arguments in the wrong order:
$order = "order1,order2,order3,";
$order = substr($order, 0, -1);
$order will now be: "order1,order2,order3"
There is also a new feature in PHP4.0.7 for rtrim(), which makes it more like the chop() function in perl. If you do have that version, you can use:
$order = "order1,order2,order3,";
$order = rtrim($order, ",");
This allows you to specify the actual characters you want to "chop off".
http://www.php.net/manual/en/function.rtrim.php
Regards