Forum Moderators: coopster

Message Too Old, No Replies

preg match help needed

         

joshm

3:39 pm on Feb 22, 2008 (gmt 0)

10+ Year Member



Hi, I am having a hell of a time trying to do this preg_match expression. Let me explain the scenario...

<hr size=1 color=black>z1 <a href="/index_1_z_2.html">z2</a> <a href="/index_1_z_3.html">z3</a> </TD></TR><TR><TD class=test>

Now, from the above code I want to grab z3

I have this:

preg_match('~<hr size=1 color=black>(.*)\.html">(.*)</a> </TD></TR><TR><TD class=test>~i',$category_page,$num_of_pages);

I am getting an undefined offset error so must be doing it wrong. I want to grab z3 which is the second (.*)

Any help much appreciated! Thanks.

PHP_Chimp

5:05 pm on Feb 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried -

echo '<pre>';
print_r($num_of_pages);
echo '</pre>';

to see what you are actually capturing with that regex?

joshm

6:01 am on Feb 23, 2008 (gmt 0)

10+ Year Member



It turned out that code was actually correct. It was some other function causing the problem.