Forum Moderators: coopster
What I'm trying to do is pull information from a page (on my own server) and take various portions of it with preg_match_all (or at least that's what I think I should use).
On page I'm looking at (example.php)
<h1>Title</h1>
<ul>
<li><a href="page1.php">Page 1</a></li>
<li><a href="page2.php">Page 2</a></li>
<li><a href="page3.php">Page 3</a></li>
</ul>
What I want is to get a multidiminsional array as follows:
Array
(
[0] => Array
(
[0] => page1.php
[1] => page2.php
[2] => page3.php
)[1] => Array
(
[0] => Page 1
[1] => Page 2
[2] => Page 3
))
Anyone help a frustrated guy out?
$data = file_get_contents('example.php');$pattern = "/href=[\"']?([^\"']?.*(php))[\"']?.*(php)?/i";
preg_match_all($pattern, $data, $data_array);$page_array = array();
foreach($data_array[0] as $key => $p){
$page_array['page'][$key] = end(explode('">',$p));
$page_array['link'][$key] = $data_array[1][$key];
}