Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:30:26+00:00 2026-05-29T06:30:26+00:00

I guess I don’t give title nicely, anyways, I can explain it better here:

  • 0

I guess I don’t give title nicely, anyways, I can explain it better here:

for example, the code is :

    <table>
            <tr>
                <td align="center"><span id="sn2">1</span></td>
                <td align="center"><div class="name">prakash</div></td>
                <td align="center"><span id="id2">student </span></td>
                <td><span id="surname1">timilsina</span></td>
                <td align="center"><span id="country1">nepal</span></td>
                <td align="center">date and time</td>
            </tr>
            <tr>
                <td align="center"><span id="sn2">2</span></td>
                <td align="center"><div class="name">aakash</div></td>
                <td align="center"><span id="id2">student</span></td>
                <td><span id="surname2">singh</span></td>
                <td align="center"><span id="country2">india</span></td>
                <td align="center">date and time</td>
            </tr>
    </table>

What we need to do using php is, get the value in array like this :

    prakash -> timilsina
    aakash  -> singh

only the name and surname from the table given. I have no idea how do I do this. hoping to get it solved here.

Thanks in advance
cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:30:26+00:00Added an answer on May 29, 2026 at 6:30 am

    Using preg_match_all this becomes quite easy. Just the regular expression that might be complex if you’re not used to it. Look up a very complete tutorial at: http://www.regular-expressions.info/

    <?php
    $data = '
    <table>
        <tr>
            <td align="center"><span id="sn2">1</span></td>
            <td align="center"><div class="name">prakash</div></td>
            <td align="center"><span id="id2">student </span></td>
            <td><span id="surname1">timilsina</span></td>
            <td align="center"><span id="country1">nepal</span></td>
            <td align="center">date and time</td>
        </tr>
        <tr>
            <td align="center"><span id="sn2">2</span></td>
            <td align="center"><div class="name">aakash</div></td>
            <td align="center"><span id="id2">student</span></td>
            <td><span id="surname2">singh</span></td>
            <td align="center"><span id="country2">india</span></td>
            <td align="center">date and time</td>
        </tr>
    </table>';
    
    $results = preg_match_all('#<div class="name">(.*?)</div>#i', $data, $matchesSurNames);
    $results = preg_match_all('#<span id="surname[0-9]+">(.*?)</span>#i', $data, $matchesNames);
    
    echo '<pre>';
    var_dump($matchesSurNames[1]);
    var_dump($matchesNames[1]);
    echo '</pre>';
    

    Will result in

    array(2) {
      [0]=>
      string(7) "prakash"
      [1]=>
      string(6) "aakash"
    }
    array(2) {
      [0]=>
      string(9) "timilsina"
      [1]=>
      string(5) "singh"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I guess I don't fully understand how destructors work in C++. Here is the
I hate writing error condition code. I guess I don't have a good approach
I guess I don't understand how the Windows Command Prompt evaluates equality. I have
I looked all over on google, I guess I just don't know what to
I don't understand this paradigm I guess? For a small single server or development
I don't want to open another Yet Another Js VS Js thread. I guess,
I guess that the # Net column is the most interesting, although I don't
I guess the question title sums it up. Is there a time when it
We have a class example and I just don't get it. I don't quite
I'm having trouble bringing back data from my PHP file. I guess I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.