I am really struggling with this and need some help.

Here is the HTML I am trying to parse into an array:

      <div id="container">
  <div id="content">

        <p class="header">&nbsp;</p>



  <table class="dottedhorizontal" width="100%">
              <tr>
                 <th class="dottedhorizontal" width="140" colspan="4">Gamer Information</th>

                 <th class="dottedhorizontal center" width="30">Gamer<br />score</th>
                 <th class="dottedhorizontal center" width="60">Last Seen</th>
                 <th class="dottedhorizontal" width="*">Last Activity or Game Played </th>
              </tr>


              <tr>
                 <td class="dottedhorizontal"><img src="images/icons/status/offline.png" width="16" height="16" alt="offline" title="offline"></td>

                 <td class="dottedhorizontal center"><img src="http://tiles.xbox.com/tiles/v-/1z/1Gdsb2JhbC9ECFZXVEoAGAFdL3RpbGUvMC8yMTAyMAAAAAAAAAD7XP2f.jpg" height="20" width="20" border="0" alt="Xbox 360 Dashboard" title="Xbox 360 Dashboard"   /></td>
                 <td class="dottedhorizontal"><img src="images/icons/flags/us.png" width="16" height="11" alt="United States" title="United States"></td>
                 <td class="dottedhorizontal">
                    <small>
                       <a href="http://live.xbox.com/member/A 43N15" target="_blank" >A 43N15</a> 




                    </small>
                 </td>
                 <td class="dottedhorizontal right"><small>9645</small></td>


                 <td class="dottedhorizontal center">&nbsp;</td>

                    <td class="dottedhorizontal"><small></small></td>

              </tr>

              <tr>
                 <td class="dottedhorizontal"><img src="images/icons/status/offline.png" width="16" height="16" alt="offline" title="offline"></td>
                 <td class="dottedhorizontal center"><img src="http://tiles.xbox.com/tiles/bG/+w/1Wdsb2JhbC9ACgRcBxwAF1EPL3RpbGUvMC8yODAwNAAAAAAAAAD6n29M.jpg" height="20" width="20" border="0" alt="Halo: Combat Evolved" title="Halo: Combat Evolved"   /></td>
                 <td class="dottedhorizontal"><img src="images/icons/flags/au.png" width="16" height="11" alt="Australia" title="Australia"></td>
                 <td class="dottedhorizontal">
                    <small>

                    <a href="http://live.xbox.com/member/a creepy person" target="_blank" >a creepy person</a></small>                     </td>
                 <td class="dottedhorizontal right"><small>360</small></td>


                 <td class="dottedhorizontal center"><small>04/28/2008<br />at 12:48am</small></td>

                    <td class="dottedhorizontal">Call Of Duty 3<small><br /><small>5 of 26 achievements, 95 of 1000 pts</small></small></td>

    </tr>

              <tr>

      </tr>


        </table>

        </div>
  </div>

What I am trying to parse out into an array is basically everything in the table individually.

For example I tried to preg_match_all

<a href="http://live.xbox.com/member/ 

get everything until

 target="_blank" >

which would return both A 43N15 and a creepy person.

This is what I tried without any luck:

$pattern = '#<a href=\"http://live.xbox.com/member/[^\<]*>.*target=\"_blank\" >#is';
$num_matches = preg_match_all($pattern, $html, $matches);


if ($num_matches == 0) {
  echo ' NO MATCHES FOUND';
} else {
  echo $num_matches . ' FOUND<br>';
  print_r($matches);
}

I hope someone can help me.

    I made some progress on this but still need some help.

    <?php
    
    $url = "http://localhost/test/New%20Folder/xbl%20html.html";
    $string = file_get_contents($url);
    
    preg_match_all('%(?<=href="http://live.xbox.com/member/)[^"]+%', $string, $matches);
    print_r($matches);
    ?>

    This Returns the Following Array:

    Array ( [0] => Array ( [0] => A 43N15 [1] => a creepy person ) )

    Now the question is how do I go about storing this into my Database?

      the $result is an array in an array

      foreach ( $matches as $item => $values )
      {
      echo $values[ 0 ] .'::'. $values[ 1 ];
      }
      

        Let's assume I don't know the last array number.....how do I loop through the array and echo out.....

        So instead of

        echo $gamertags[ 0 ] .'::'. $gamertags[ 1 ];

        Something like:

        foreach ($gamertag as $item => $gamertags )
        {
        echo $gamertags[  ];
        echo '<br />';
        }

        This gives me an error of course, so I'm not sure how to loop through until it gets the last array variable.

          I'm also having some issues with the following:

          <td class="dottedhorizontal">Halo 3<br /><small>Matchmaking- searching
          in Team Slayer<br /><small>21 of 49 achievements, 510 of 1000 pts</small></small></td>
          
          AND
          
          <td class="dottedhorizontal">Xbox 360 Dashboard<br /><small>Listening to music</small></td></tr>

          All I want to Match(respectively) is

          Halo 3 Matchmaking- searching
          in Team Slayer
          
          AND
          
          Xbox 360 Dashboard Listening to music

          What I have tried is:

          preg_match_all('%(?<=td class="dottedhorizontal">)[a-zA-Z0-9]+<br /><small>[a-zA-Z0-9]+<br /><small>+%', $string, $currently);

          Along with other things and I cannot seem to get the results that I want.

            11 days later
            Write a Reply...