Extracting the essence!
| From: | #Linux | Date: | Sun, 14 Apr 2002 18:36:02 +0000 |
| Subject: | Extracting the essence! | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-18495@lists.php.net to get a copy of this message | ||
Hi ppl!
I want to strip html sites from the tags, only leaving the data from a <table> entity.
The info i would like to insert into a mysql table.
Have tried to use the following code with various $dokument variables, but it dont preform as
expected.
<?php
$dokument = file("http://localhost/php/index.html");
$search = array ("'<script[^>]*?>.*?</script>'si",
"'<style[^>]*?>.*?</style>'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'",
"'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e");
$replace = array ("",
"",
"\\1",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169)
//,chr(\\1)
);
$test= preg_replace ($search, $replace, $dokument);
echo $test;
php?>
The output of this script comes as:
Array
Stan