Some PHP CLI algorithms