Hi is it possible to make a script that allows a user to select a portion of a page and extract the html code. Thanks
basically what i want is to for a user to be able to enter a site and then highight the area they want and the script to return the html, is this possible? and if so how? Thanks
Use this function I have came up with, it is good because it doesn't require regular expression. <?php // USAGE $str = "<b>Bold Text 1</b><b>Bold Text 2</b>"; $boldedText = between("<b>", "</b>", $str); print_r($boldedText); // FUNCTION function between($start, $end, $source) { while ($s != strlen($start)) { $s = strpos($source, $start, $s) + strlen($start); if ($s == strlen($start)) continue; $r[] = substr($source, $s, strpos($source, $end, $s) - $s); } return (count($r) <= 1 ? $r[0] : $r); } ?> PHP:
What's good about that? And ojsimon, that might be possible, but it would be very complicated. And you'd need JavaScript or Flash as well. No one here is going to code it just because... Perhaps you want to try your luck in the Buy sell trade section.
Your script has a lot of function calls (also inside loops, which is expensive). I wouldn't be too sure about the speed in this case. With RegEx, you can do the job with one single function call, while yours has quite a lot.