PHP can't get the width of the browser window, because it runs on the server not on the client. But JS can. In such cases, usually, pass parameters to the server via AJAX. Here's an example: should look Like the PHP code to query the resolution of the client browser?
Maybe You'd better edit the required code is not in PHP but in JS ?