remshad Posted October 1, 2011 Share Posted October 1, 2011 while i am coding to find text between some html tags ,, am getting an error... Notice: Undefined offset: 1 in D:\xamp\xampp\htdocs\file\dash.php on line 48 my code is at line 47 and 48 is preg_match('/<td class="trow1" rowspan="3" valign="top">(.*)<\/td> /',$dat,$regs); echo $etc=$regs[1]; i am thinking copy data from </td> <td class="trow1" rowspan="3" valign="top"> Posts per day: <strong>6.03</strong><br /> Threads per day: <strong>3.78</strong><br /> Members per day: <strong>4.76</strong><br /> Posts per member: <strong>1.27</strong><br /> Replies per thread: <strong>0.6</strong> </td> </tr> this much Posts per day: <strong>6.03</strong><br /> Threads per day: <strong>3.78</strong><br /> Members per day: <strong>4.76</strong><br /> Posts per member: <strong>1.27</strong><br /> Replies per thread: <strong>0.6</strong> Quote Link to comment Share on other sites More sharing options...
Buddski Posted October 1, 2011 Share Posted October 1, 2011 You are getting that error because nothing is found at index 1 of your $reg array. Try print_r on the array and see what is in there.. My guess is that your RegEx is wrong. Quote Link to comment Share on other sites More sharing options...
trq Posted October 1, 2011 Share Posted October 1, 2011 preg_match will return false if no match is found. You should check that before assuming it matched anything. Quote Link to comment Share on other sites More sharing options...
remshad Posted October 1, 2011 Author Share Posted October 1, 2011 can you help me to make a better regexp for this situation .....? i just want to copy this html code Posts per day: <strong>6.03</strong><br /> Threads per day: <strong>3.78</strong><br /> Members per day: <strong>4.76</strong><br /> Posts per member: <strong>1.27</strong><br /> Replies per thread: <strong>0.6</strong> from </td> <td class="trow1" rowspan="3" valign="top"> Posts per day: <strong>6.03</strong><br /> Threads per day: <strong>3.78</strong><br /> Members per day: <strong>4.76</strong><br /> Posts per member: <strong>1.27</strong><br /> Replies per thread: <strong>0.6</strong> </td> </tr> Quote Link to comment Share on other sites More sharing options...
Buddski Posted October 1, 2011 Share Posted October 1, 2011 Here is a pattern that should do the trick /\<td class="trow1" rowspan="3" valign="top"\>(.*)\<\/td\>/s Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.