Darcey Wayment demonstrate the pH dependent extraction of drugs at the 2009 Forensic Science Workshop

Darcey makes a point about the pK of the functional groups on the drug

Here he shows how to adjust the pH of the solutions

and here is the difference in the solution dependent upon the pH