I created a function to loop through the values in a paragraph and search for specific values (the values between the div tags). But I can't seem to get it to work. Can someone help me? Here is my code. PHP code: //pre set vars $uppervar = 10; $lowervar = 1; $intpos = 0; $finalpos = 0; $num = 0; $finaldata = ""; //get data between limits while($num < $upperval) { $num += 1; //get var name $varname = 'width:740px; margin-left:auto; margin-right:auto; text-align:left;" id="comment_' . $num . '_'><b><a style="color: #347C17;" id="comment_' . $num . '_'; //get position of 38 bytes behind $varname (should be beginning of div tag) $intpos = (strpos($data, $varname) - 38); //append data if higher than lowerval if($num >= $lowerval) { //get position of 6 bytes after </div> (should right after closing div tag) $finalpos = (strpos($data, '</div>', $intpos) + 6); $adata = substr($data, $intpos, $finalpos); //append data so $finaldata should be divs 1-10 by the end of the loop $finaldata .= $adata; } } //echo data echo("$finaldata"); } Code (markup): $data value: <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_1_">test1</a></b></div> <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_2_">test2</a></b></div> <div style="background-color:#CCCCCC; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_3_">test3</a></b></div> <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_4_">test4</a></b></div> <div style="background-color:#CCCCCC; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_5_">test5</a></b></div> <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_6_">test6</a></b></div> <div style="background-color:#CCCCCC; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_7_">test7</a></b></div> <div style="background-color:#CCCCCC; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_8_">test8</a></b></div> <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_9_">test9</a></b> </div> <div style="background-color:#CCCCCC; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_10_">test10</a></b></div> <div style="background-color:#333333; width:740px; margin-left:auto; margin-right:auto; text-align:left;"><b><a style="color: #347C17;" id="comment_11_">test11</a></b></div> Code (markup): Thanks to whoever can help me. ~imozeb
That is all the html of the page. I get the $data data via f_read(). That works because if I don't have the code their it outputs all of the divs, but I only want the data between the upper and lower limits. How would I find the tags. I tried strpos to find the start of the tag and strpos again with an offset of 5 to find the end of the tag. Then I tried to use substr to cut just the data between the open and close div tags. It should work, but I keep getting crazy values. Please help me!!! ~imozeb
Thanks. I didn't use curl but I did see what you did with substr. ($end-$start) I checked the PHP site and I found out that substr's last value is the length not the last value!!! OMG I gave myself so much frustration for nothing! LOL