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 1002565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:50:56+00:00 2026-05-16T07:50:56+00:00

I’m a PHP newbie. I’m trying to use preg_match_all function in the below program

  • 0

I’m a PHP newbie. I’m trying to use preg_match_all function in the below program to find all subjects with their marks, but I’m getting only one match. I have been struggling with this for 5 hours. Can someone help me in figuring out whats wrong? Thanks in advance.

<?php
$semArray="<B>STUDENTS NAME (7ab05cs001) </B><br><br><br><br><hr><table><tr><td><b>Semester:</b></td><td><b>2</b></td><td></td><td> &nbsp;&nbsp;&nbsp;&nbsp;<b> Result:&nbsp;&nbsp;FIRST CLASS </b></td></tr></table><hr><table><tr><td width=250>Subject</td><td width=60 align=center>External </td><td width=60 align=center>Internal</td><td align=center width=60>Total</td><td align=center width=60>Result</td></tr><br><tr><td width=250><i>Engineering Maths - II (06MAT21)</i></td><td width=60 align=center>51</td><td width=60 align=center>16</td><td width=60 align=center>67</td><td  width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Engineering Chemistry (06CHE22)</i></td><td width=60 align=center>40</td><td width=60 align=center>17</td><td width=60 align=center>57</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Computer Concepts and C Programming (06CCP23)</i></td><td width=60 align=center>70</td><td width=60 align=center>23</td><td width=60 align=center>93</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Computer Aided Engineering Drawing (06CED24)</i></td><td width=60 align=center>50</td><td width=60 align=center>16</td><td width=60 align=center>66</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Basic Electronics (06ELN25)</i></td><td width=60 align=center>42</td><td width=60 align=center>17</td><td width=60 align=center>59</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Computer Programming Lab (06CPL26)</i></td><td width=60 align=center>46</td><td width=60 align=center>24</td><td width=60 align=center>70</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Engg. Chemistry Lab (06CHEL27)</i></td><td width=60 align=center>41</td><td width=60 align=center>19</td><td width=60 align=center>60</td><td width=60 align=center><b>P</b></td></tr><tr><td width=250><i>Environmental Studies (06CIV28)</i></td><td width=60 align=center>48</td><td width=60 align=center>25</td><td width=60 align=center>73</td><td width=60 align=center><b>P</b></td></tr></table><br><br><table><tr><td></td><td></td><td>Total Marks:</td><td> 545 &nbsp;&nbsp;&nbsp; </td></tr></table>";
function get_result_for_this_sem($semArray)
{

preg_match("/Semester:<\/b><\/td><td><b>(.)<\/b>/",$semArray,$temp1);
$sem_no=$temp1[1];
preg_match("/Result:&nbsp;&nbsp;(.+)<\/b><\/td><\/tr><\/table><hr><table>/U",$semArray,$temp2);
$sem_final_result=$temp2[1];
preg_match_all("/<i>((.+?)\((.+?)\))<\/i><\/td><td width=60 align=center>([0-9]{1,3})<\/td><td width=60 align=center>([0-9]{1,2})<\/td><td width=60 align=center>([0-9]{1,3})<\/td><td  width=60 align=center><b>(.)<\/b><\/td><\/tr>/",$semArray,$temp3,PREG_SET_ORDER);

print_r($temp3);

}
get_result_for_this_sem($semArray);
?>

Here is the output that I get:

Array ( [0] => Array ( [0] => Engineering Maths - II (06MAT21)511667P  [1] => Engineering Maths - II (06MAT21) [2] => Engineering Maths - II [3] => 06MAT21 [4] => 51 [5] => 16 [6] => 67 [7] => P ) )
  • 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-16T07:50:57+00:00Added an answer on May 16, 2026 at 7:50 am

    You’ve copied and pasted the literal HTML into your regex. There’s a double-space in the first subject’s section that doesn’t exist in the following sections, and you’re matching that double space literally.

    <td  width=60 align=center><b>P</b></td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 543k
  • Answers 543k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The convention is to ask a question in the name.… May 17, 2026 at 6:42 am
  • Editorial Team
    Editorial Team added an answer It's probably being active for 20 seconds. Checking that the… May 17, 2026 at 6:42 am
  • Editorial Team
    Editorial Team added an answer Well, commits DO always point to the entire tree/branch history… May 17, 2026 at 6:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.