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 6880557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:59:21+00:00 2026-05-27T04:59:21+00:00

iwant to get the video url from a object/embed html source. i read i

  • 0

iwant to get the video url from a object/embed html source. i read i can use regular expression to get it but me and regular expression are no friends

so heres what i have:

<?php 

function src($text) {
    $text = str_replace('"', '', $text);
    $text = str_replace('src=', '', $text);
    $temporary = explode('<embed', $text);
    $temporary = $temporary[1];
    $temporary = explode(' ', trim($temporary));
    return $temporary[0];
} 

$html = '
<object width="180" height="220">
    <param name="movie" value="http://www.domain.com/video/video1.swf"></param>
    <embed src="http://www.domain.com/video/video1.swf" type="application/x-shockwave-flash" width="180" height="220"></embed>
</object>
'; 

echo src($html);

this works but is it better in regular expression?

i am using lamp

  • 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-27T04:59:22+00:00Added an answer on May 27, 2026 at 4:59 am

    A regular expression is better for this case because the src might never be at the first attribute, therefore this won’t work.

    Here’s what I recommend:

    function src($html) {
     if(preg_match('#<embed[^>]*?src=["\'](.*?)["\'](.*?)></embed>#si', stripslashes($html), $src)) {
      return $src[1];
     }
     return ''; // or any other error if you need
    }
    
    echo src($html);
    

    will output: http://www.domain.com/video/video1.swf

    [^>] matches a single character that is not contained within the brackets. [^>] matches any character other than >

    ["\'] matches src=" or src='

    (.*?) Dot (.) means match any character. Star (*) means zero or more times. And question mark (?) means be greedy and keep going as long as the pattern still matches. Put it all together, it means try and match any character, zero or more times, and get as many as you can

    /i is case insensitive

    Here’s more info:

    http://en.wikipedia.org/wiki/Regular_expression

    http://www.regular-expressions.info/reference.html

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

Sidebar

Related Questions

I use until now this code for saving video that i get from UIImagePickerController
I want to use oembed to get the embed code from youtube links with
Does anybody knows how to get url to video file from this url: http://vk.com/video_ext.php?oid=6492&id=141771975&hash=a984f2edb68fc4f7
I've found how to pause and play the video using jquery $(video).get(0).play(); $(video).get(0).pause(); But
I get a feed which consists of a URL pointing to the videos from
For image scanning purposes, I'd like a pixel (which I can get from a
I want to get Video ID for YouTube or Vimeo via its Embed code
I want to get exact video link from some streaming video resources like you-tube
I want to get the v=id from YouTube’s URL with JavaScript (no jQuery, pure
My code can upload the video to YouTube successfully, I want to get the

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.