Changer dimensions d'un objet
Bonjour,
j'ai une chaine de caractère comme suis :
Code:
1 2 3 4 5 6
|
<object width="560" height="340">
<param name="movie" value="http://www.youtube.com/v/q4xDFw5WQlk&hl=fr&fs=1&"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/q4xDFw5WQlk&hl=fr&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed>
</object> |
j'utilise ma fonction replace de cette facon
Code:
1 2 3 4 5 6 7 8 9 10
|
$youtube='<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/q4xDFw5WQlk&hl=fr&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/q4xDFw5WQlk&hl=fr&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>';
$pattern = '(<object[^>]width=")([0-9]+)(" height=")([0-9]+)(".+width=")([0-9]+)(" height=")([0-9]+)(".+</object>)';
$pattern = '(<object[^>]width=")([0-9]+)(" height=")([0-9]+)(".+width=")([0-9]+)(" height=")([0-9]+)(".+</object>)';
$replacement = '$1' . '125'. '$3'.'250'.'$5'.'125'.'$7'.'250'.'$9';
echo preg_replace($pattern, $replacement, $youtube); |
Mais j'ai un message d'erreur de firefox :'(
Citation:
Warning: preg_replace() [function.preg-replace]: Unknown modifier '(' in C:\wamp\www\test\preg.php on line 9
J'ai essayé de modifier ma variable pattern
Code:
1 2
|
$pattern = '/(<object[^>]width=")([0-9]+)(" height=")([0-9]+)(".+width=")([0-9]+)(" height=")([0-9]+)(".+</object>)/'; |
ms ceci ne fonctionne toujours pas :s
Merci de m'aider
il faut un délimiteur au pattern
bonjour
initialise le pattern avec : $pattern = "/pattern/". Ca ira tout de suite mieux.
8O
fx