Advertisement
shapoval

Check if a user is using an iPhone, iPad, iPod or iPod touch

May 23rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.23 KB | None | 0 0
  1. $userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
  2. $re = "/^(?:Mozilla\/5.0|QwantMobile\/2.0|Opera\/9.80) \((?:iPhone|iPhone (?:.){2}|iPad|iPod|iPod touch);/m";
  3. preg_match($re, $userAgent, $iOsMatches);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement