Moving from JS to PHP functions.