We resorted to only giving PHP ready to transmute data, so it didn’t handle any of the manipulation unless it was straightForward based on our own criteria, but anything involving too much searching or filtering (yes I realize there are other problems here, but our scale was large enough that these problems had to be tackled piecemeal, and aren’t relevant beyond that for this discussion)
Ultimately I’ve had less issues with Python for this type of workload and is eventually where we moved.