Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 444835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:18:37+00:00 2026-05-12T21:18:37+00:00

I am writing temporary PHP script to update MySQL database of my vBulletin forum.

  • 0

I am writing temporary PHP script to update MySQL database of my vBulletin forum.

Here’s what it does. It finds any entry that has a [youtube][/youtube] code. And then it has to replace that code with a link to the youtube video instead.

So, here is an example of what I have to take:

$string = <<<END
Hi everyone! Check out this video that I just found on YouTube!

[youtube]<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Md1E_Rg4MGQ&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Md1E_Rg4MGQ&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>[/youtube]
END;

And I have to make that look like this instead:

[URL=http://www.youtube.com/watch/?v=Md1E_Rg4MGQ]http://www.youtube.com/watch/?v=Md1E_Rg4MGQ[/URL]

I’m getting a headache working with the Regex. I don’t have enough experience with Regex to figure out what to do.

It has to look something like this:

$string = preg_replace("#\[youtube\]?????\[/youtube\]#i", "[URL=http://www.youtube.com/watch?v=$1]http://www.youtube.com/watch?v=$1[/URL]", $string);

Help Please! ^_^

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:18:37+00:00Added an answer on May 12, 2026 at 9:18 pm

    Something like this perhaps?

    $string = preg_replace('#\[youtube\].*?name="movie" value="(.*?)".*?\[/youtube\]#i', "[URL=$1]$1[/URL]", $string);
    

    Note that this is limited in that it expects a string name="movie" value="????????????????" format precisely – technically, there are other valid HTML constructs with the same meaning but different order, etc. The ideal solution would be to use some sort of DOM parser to grab the value of the movie attribute, but if you know people will always be using that exact format (i.e. if that’s copy the copy/paste from youtube always is or the like) then regex can suffice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some PHP that will interact with MySQL to 1. upload and 2.
I am writing a php site using a mysql database for a class of
I am writing a script that uses a temporary directory, and I would like
When it comes to writing custom MySQL database-driven PHP session management for a VERY
first of all, a preface: I'm writing a java class that creates temporary tables
Writing htaccess that allows me to remove index.php from the URL can confuse search
I am writing a build script that gets all the source code for a
I'm writing a PHP script to scrape data from the web. End-result, I want
I'm writing a php-mysql application. The application allows the user to run a search
I'm writing a webapp that will only be used by authenticated users. Some temporary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.