PHP port of jQuery