'http://(video\.google)\.com/videoplay\?docid=(.*?)', 'src' => 'http://video.google.com/googleplayer.swf?docId=%s', 'width' => 425, 'height' => 350, ); $params['youtube'] = array( 'pattern' => 'http\://www\.(youtube)\.com/watch\?v=(.*?)', 'src' => 'http://www.youtube.com/v/%s', 'width' => 425, 'height' => 350, ); // Construction du pattern global $patterns = array(); foreach ( $params as $service => $param ) { $patterns[] = $param['pattern']; } $pattern = '`^(?:'.join('|', $patterns).')$`'; preg_match($pattern, $uri, $match); // Retour des resultats return array( 'width' => $params[$match[1]]['width'], 'height' => $params[$match[1]]['height'], 'src' => sprintf($params[$match[1]]['src'], $match[2]) ); } // end of 'processVideoUri()' $video = processVideoUri('http://www.youtube.com/watch?v=X2BEhk1fqZo'); //$video = processVideoUri('http://video.google.com/videoplay?docid=3163263343187879320'); ?>