cstegner Posted March 2, 2007 Share Posted March 2, 2007 I am working to make a script that will replace a bbcode type tag with the correct embed html for the media type. Here it will make more sense if I just show you. here is the sample string: The idea of all of the possibilities that iValueRich.com will bring the community just blows my mind. I hope everyone is ready for it! [quicktime "991cc705c6e8be7b074aeca3fe0f52e1.mov"] [quicktime "991cc705c6e8be7b074aeca3fe0f52e1.mov"] I was thinking that I could use preg_replace, however two problems I am having a tough time getting it to work at all in my object and even if I do I could use some help with the expression. Here is what I was kind of thinking // add media into blog post public function add_media() { $patterns[0] = 'expression for [quicktime "whatever"]'; $patterns[1] = 'expression for [windows_video "whatever"]'; $patterns[2] = 'expression for [flash "whatever"]'; $replacements[0] = 'proper embed code'; $replacements[1] = 'proper embed code'; $replacements[2] = 'proper embed code'; $this->blog = preg_replace($patterns, $replacements, $this->blog); } I have all of the embed code. Another problem how would I pass the "whatever" to the embed code? Please any help, or otherways to accomplish this, anything. Link to comment https://forums.phpfreaks.com/topic/40879-need-help-with-fancy-type-of-bbcode-seriosuly-no-joke-immeditaley/ Share on other sites More sharing options...
cstegner Posted March 2, 2007 Author Share Posted March 2, 2007 Solved! Once I woke up a little I realized that I was making things much too difficult. I ended up going this route. // add media into blog post public function add_media() { $blog_one = explode('[:', $this->blog); if(count($blog_one) > 1) { for($i=0; $i <= count($blog_one); $i++) { $blog_two = explode(':]', $blog_one[$i]); if(count($blog_two) > 1) { $blog_three = explode('|', $blog_two[0]); $media_type = str_replace(' ', '', $blog_three[0]); $media_url = str_replace(' ', '', $blog_three[1]); switch ($media_type) { case "quicktime": $blog_two[0] = ' <object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="256" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="/uploads/' . $media_url . '"> <param name="qtsrc" value="/uploads/' . $media_url . '"> <param name="autoplay" value="true"> <param name="loop" value="false"> <param name="controller" value="true"> <embed src="/uploads/' . $media_url . '" qtsrc="/uploads/' . $media_url . '" width="320" height="256" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed> </object>'; break; case "windows_video": $blog_two[0] = 'embed code'; break; case "flash": $blog_two[0] = 'embed code'; break; } $blog_one[$i] = join($blog_two); } } $this->blog = join($blog_one); } } this owrks perfect for [: quicktime | whatever.mov :] however many times its inserted between whatever text, etc. Link to comment https://forums.phpfreaks.com/topic/40879-need-help-with-fancy-type-of-bbcode-seriosuly-no-joke-immeditaley/#findComment-198039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.