
Untitled
By: a guest on
Jul 6th, 2012 | syntax:
None | size: 0.64 KB | hits: 9 | expires: Never
PHP- How do I search through an HTML document and extract certain strings in php?
<?php
$str = file_get_contents("comment.txt");
preg_match_all ('/^(user/)/[A-Z0-9][A-Z0-9_-]+"$/i', $str, $preg);
print_r ($preg);
?>
Array ( [0] => Array ( ) [1] => Array ( ) )
<html>
<body>
<a href="/user/boy30" />
<a href="/user/boy31" />
<a href="/user/boy32" />
</body>
</html>
Array
(
[0] => Array
(
[0] => "/user/boy30"
[1] => "/user/boy31"
[2] => "/user/boy32"
)
[1] => Array
(
[0] => boy30
[1] => boy31
[2] => boy32
)
)