Detect iPhone & iPad in PHP

Oh and this works for the iPod touch as well.  I’m aware that there are great mobile detection solutions out there but I was working with a client recently that has a flash logo animation on their site and unfortunately the source file was unavailable to tweak.  To accomplish this I applied a “simple fix” by using the following code to display alternate content if the visitor is using an Apple device.

if (preg_match("/iP(hone|od|ad)/i", $_SERVER['HTTP_USER_AGENT'])) {
    // Display iSpecific content
} else {
    // Display other content