self::extractUInt32( $fileSize ), 'fourCC' => $fourCC, 'chunks' => array(), ); $numberOfChunks = 0; // Find out the chunks while ( !feof( $file ) && !( $numberOfChunks >= $maxChunks && $maxChunks >= 0 ) ) { $chunkStart = ftell( $file ); $chunkFourCC = fread( $file, 4 ); if ( !$chunkFourCC || strlen( $chunkFourCC ) != 4 ) { return $info; } $chunkSize = fread( $file, 4 ); if ( !$chunkSize || strlen( $chunkSize ) != 4 ) { return $info; } $intChunkSize = self::extractUInt32( $chunkSize ); // Add chunk info to the info structure $info['chunks'][] = array( 'fourCC' => $chunkFourCC, 'start' => $chunkStart, 'size' => $intChunkSize ); // Uneven chunks have padding bytes $padding = $intChunkSize % 2; // Seek to the next chunk fseek( $file, $intChunkSize + $padding, SEEK_CUR ); } return $info; } /** * Extract a little-endian uint32 from a 4 byte string * @param string $string 4-byte string * @return int */ public static function extractUInt32( $string ) { $unpacked = unpack( 'V', $string ); return $unpacked[1]; } };