0

Well this is the html code:

<?

    $html ='<table cellspacing="0" cellpadding="0" class="mytable">
                                         <tr>
                                            <th class="first-td">Home <span>Live</span></th>
                                            <th>type</th>
                                            <th>Status</th>

                                          </tr>
                                                                              <tr>
                                            <td width="40%" class="first-td">text1</td>
                                            <td>info</td>
                                            <td class="status"><span class="identify">asdf2</span></td>

                                          </tr>
                                                                                <tr>
                                            <td width="40%" class="first-td">text2</td>
                                            <td>info</td>
                                            <td class="status"><span class="identify2">asdf</span></td>
    ';

    $pattern = '/<span class="identify">(.*?)<\/span>/im';
    preg_match_all($pattern, $html, $matches);
    print_r($matches);

    ?>

But what I want is to get back the word text, which is the td in that cell where class is identify. Or maybe if it is easier when class is identify print 1, or if it is identify2 press 0.

So I wna tin pseudocode like this:

If class-identify print the td-class=first-td of that cell
2
  • 1
    Why not just use a real HTML-parsing tool? Commented Jul 5, 2012 at 21:56
  • indeed Commented Jul 5, 2012 at 22:01

1 Answer 1

1

I can recommend you to use xpath like in this example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.