tobeyt23 Posted September 10, 2010 Share Posted September 10, 2010 I am trying to check my youtube code value and see if &rel=0 has been added to it and if not added it. I suck at regular exp can someone help? Link to comment https://forums.phpfreaks.com/topic/213062-regular-exp-help/ Share on other sites More sharing options...
Psycho Posted September 10, 2010 Share Posted September 10, 2010 Well, unless you want to provide more specifics such as examples of the input data and the location of where the parameter will go I don't think you need regular expression. if(strpos($value, '&rel=0')===false) { $value .= '&rel=0'; } Link to comment https://forums.phpfreaks.com/topic/213062-regular-exp-help/#findComment-1109618 Share on other sites More sharing options...
tobeyt23 Posted September 10, 2010 Author Share Posted September 10, 2010 sorry basically im taking the you tube embed code which someone else is adding to our db. So i want to change the height and with which i am doing with: $vid = '<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/zMQ6LfyA-0o?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/zMQ6LfyA-0o?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>'; $search = array('<embed', '></embed>'); $replace = array('<param name="wmode" value="transparent" /><embed', ' wmode="transparent"></embed>'); $find = array('/height(=)(".*?")/', '/width(=)(".*?")/'); $replacement = array('height="175"', 'width="200"'); $vid = str_replace($search, $replace, $vid); $vid = preg_replace($find, $replacement, $vid); I also need to then see if the rel=0 is added to the value="" and add it if not Link to comment https://forums.phpfreaks.com/topic/213062-regular-exp-help/#findComment-1109625 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.