Web Hosting Talk







View Full Version : Stripping some html code with php


saghir69
03-29-2005, 03:08 PM
i've done it in past using vb , but is it possible to do it with php?

i want to get some text within a certain tag in the html of a page.

MarkIL
03-29-2005, 03:33 PM
Sure, just use regular expressions... Examples are numerous. Google, as always, is your best friend on this.

saghir69
03-29-2005, 07:18 PM
can you give me an idea what i'm looking at, i'm not too good with php. what do i search for on google?

i tried searching for stripping a html page but it don't bring up much.

MarkIL
03-30-2005, 02:56 AM
Something like "php regexp tutorial" ;)

Or, perhaps, "extract tag php regexp".

innova
03-30-2005, 06:46 PM
Why not post an example of what it is YOU are trying to do?

HR Justin
03-30-2005, 07:15 PM
Originally posted by saghir69
i've done it in past using vb , but is it possible to do it with php?

i want to get some text within a certain tag in the html of a page.


Something like this?
<?php

$string = "<title>This is the title</title>";
preg_match("/<title>(.*)<\/title>/i", $string, $matches);
print $matches[1];

//Outputs "This is the title"

?>

saghir69
03-30-2005, 07:38 PM
hey thanks a lot, thats what i needed. i'll play around with it.

Scott.Mc
03-30-2005, 07:50 PM
Or have alook at
www.php.net/strip_tags