0

In my table I have a field "youtube" where the user can add a Youtube or Vimeo link. The Youtube links can be played directly, the Vimeo links which looks like:

https://vimeo.com/22614651XX

needs to be replaced by:

https://player.vimeo.com/video/22614651XX

Can this be done with SQL or should it be done in PHP? In PHP I found the substr() Function where I can split a string, but I have no clue how to deal with the numbers as they can vary in length...

3
  • 3
    If the urls are well formed the simplest thing is a single dumb replace()/str_replace() swapping https://vimeo.com/ for https://player.vimeo.com/video/ Commented Nov 14, 2017 at 17:09
  • MySQL's REPLACE function or PHP's str_replace function should to the trick just fine. Commented Nov 14, 2017 at 17:14
  • Something like REPLACE(column, 'https://vimeo', 'https://player.vimeo') should do it. Use that with an update if you want it stored that way. Commented Nov 14, 2017 at 17:33

1 Answer 1

1

thank you for your assistance :-)

UPDATE wp_awa_upload
SET youtube = REPLACE(youtube, 'https://vimeo.com/', 'https://player.vimeo.com/video/')
WHERE youtube like "%vimeo%"

does the trick :-)

Kind Regards,

Stefan

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.