Jump to content

Recommended Posts

Okay I'm trying to make a blog-type-thing where when the user wants to use a video it will take the info given and turn it into code. The code saying you want to use a video is this

[video title="video title" url="C:\...\video.flv" height="260" width="320"][/video]

But I cant figure out how to use PHP to get the title, url, height, and width and then set each as a variable. I tried using "preg_match()" but I cant get it to work. If you could give me a hand with this that would be awesome.

 

Thanks,

Daniel

Link to comment
https://forums.phpfreaks.com/topic/188621-get-text-between-tags/
Share on other sites

$string = '[video title="video title" url="C:\...\video.flv" height="260" width="320"][/video]';
preg_match('/(.*title=")(.*)(" url=")(.*)(" height=")(\d*)(" width=")(\d*)(".*)/', $string, $matches);
print_r($matches);
$title = $matches[2];
$filename = $matches[4];
$height = $matches[6];
$width = $matches[8];

 

How the regexp is working:

(.*title=") - Find any number of characters up to ' title=" ' (whats before title)

(.*) - Find any number of characters (title)

(" url=") - Up to ' " url=" ' (what's between title and filename)

(.*) - Find any number of characters (filename)

(" height=") - Up to ' " height=" ' (what's between filename and height)

(\d*) - Find any number of digits (height)

(" width=") - Up to ' " width=" ' (what's between height and width)

(\d*) - Find any numberof digits (width)

(".*) - Up to ' " ' and then find any number of characters remaining (.*)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.