After building a list of items in a string (ie “x1,x2,x3,x4,”) I typically find myself needing to remove the last comma. After using this for the longest time:
$str = substr($str,0,strlen($str)-1);
$str = substr($str,'',-1);
This will actually remove the last character whatever it is so be careful, for my uses it’s perfect.
I know this is not novel but it’s elegant and these are the things that make my day.