View Single Post
Old 06-28-2011, 09:06 PM  
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Quote:
Originally Posted by fris View Post
why not just create a new custom bb code, or are you trying to replace all the current ones via the database?
Yes this is to replace the current ones in the database.
Quote:
Originally Posted by V_RocKs View Post
I believe it is a problem that has more to do with where you are putting the code. I added a small piece to the code to remove the other shit at the end:

Here is the code from my example.. You can drop it into a php extension file and run it on your sever to see the output and play with it yourself...

Code:
<?

$text = '[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - &#x202a;Bill O\'Reilly Interviews Rapper Lupe Fiasco - 06/20/11&#x202c;&rlm;[/ame]';

$text3 = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);


echo "$text <br><br>$text3";

$text5 = '[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]';
echo "<br><br>$text5";

?>
And the output is:

[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

Which is:

line 1 - original string
line 2 - modified string
line 3 - what you wanted.

Notice 2 and 3 match.
Thanks. I have a test database that I am running the test configurations on before I mess with the live forum. 2.5Million posts... so I cant screw it up.
The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote