|
Posted by Dimitris Mexis on 09/17/05 21:53
Tyrone Slothrop wrote:
> On Sat, 17 Sep 2005 14:52:11 +0300, Dimitris Mexis <dmexis@sparks.gr>
> wrote:
>
>
>>I have created a small script that searches a word with eregii through a
>>page. Assume that it found the word, and reports me the string,
>>1) Can I take the line of this word is shown...?
>>2) Can I create a link to this part of this page?
>
>
> You may want to use the file() function which treats each line of a
> file as an array.
> $lines = file('/path/to/file');
> Then find which line numbers contain the word:
> foreach ($lines as $line_num => $line) {
> if (/*Your regex here run on $line*/) {
> $match[] = $line_num;
You initialize an array, without declaring and without specifying limits?!?!
Isn't this untrusted for memory leak?I mean this could be very
unpleasant overflow...right?
> }
> }
> //Then display the lines
> foreach ($match as $which) {
> echo "a href=\"#$which\">".$lines[$match]."\<a>\";
> }
This last one does not function...the error is
Parse error: parse error, unexpected $ in /var/www/html/seek_url.php3 on
line 70
and to tell you the truth it is the first time i see something like
this, and i am new with php and this string-situation...i try to learn it...
What do you suggest to do? I have replaced the $ at times or the echo I
command I turned it to print... didn't work...
[Back to original message]
|