daneilair Posted January 15, 2010 Share Posted January 15, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/188621-get-text-between-tags/ Share on other sites More sharing options...
Catfish Posted January 20, 2010 Share Posted January 20, 2010 $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 (.*) Quote Link to comment https://forums.phpfreaks.com/topic/188621-get-text-between-tags/#findComment-998523 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.