Hello, i'v looked it up on php.net but was a little confused, so I gotta ask around Say I had a text file containing a code such as <b>texttexttexttext</b><i123>[B]clay[/B]</i><br><u>ping</u> Code (markup): I want to get the data between the <i123> and </i> tags, excluding the <i123> and </i>, and store it in a variable called $data, so when I put the code: echo "$data"; Code (markup): the text clay will be displayed. Thanks!
Well I put this together real quick, it doesnt use preg_match, but you can try it and give it a go: <?php $page=file_get_contents("file.htm"); // change to correct file name eregi("<i123>(.*)</i>", $page, $result); $data=$result[1]; echo $data; ?> PHP:
One problem, when I try to get the content from a page from another site (i'm using a myspace url) it grabs all of the content of the myspace page and puts it into the variable too. Any suggestions? Edit: Fixed it, thank you, smatts9!
<? $string = '<b>texttexttexttext</b><i123>clay</i><br><u>ping</u>'; preg_match('/<i123>([^<]*)<\/i>/', $string, $match); echo $match[1]; //or $data = $match[1]; echo $data; ?> PHP: