Search and replace

Discussion in 'PHP' started by sps.srk, Mar 12, 2009.

  1. #1
    Hello All.
    I am new in PHP so plz help me.

    In the given set of code: i want to replace width=240 and height =185.

    i am able to replace but problem is that, the given 'width="480"' and height="295" not fixed. I just want to do is, replace the existing width with 240 and existing height with 185. l plz help me.

    <object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/F8I0R6bo-1o&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/F8I0R6bo-1o&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>

    Thanks
    Santosh;)
     
    sps.srk, Mar 12, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $html = preg_replace('/width="\d+"/', 'width="240"', $html);
    Code (markup):
     
    SmallPotatoes, Mar 12, 2009 IP
  3. Stylesofts

    Stylesofts Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello..

    U just need to replace the width and height values..
    i seems you want to play the youtube video. I hope this is what u mean

    just use the following codes..


    <object width="240" height="185"><param name="movie" value="http://www.youtube.com/v/F8I0R6bo-1o&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/F8I0R6bo-1o&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="240" height="185"></embed></object>
     
    Stylesofts, Mar 13, 2009 IP