The simplest way I could think of would be to use a regex:

/^(.*Jim.*)$/g (g=global)

and then using $1 (the content of the parenthesis), this would give you the
whole line containing "Jim".


ps: is perl syntax, needs to be adjusted for php...

> Hi there:
> I wanna select a line from a table which is in a php page resulted of a
> mysql_query
> So far what i have is a way to search the text from only line and
> then limit
> the characters in substr ( )
> Thats a really wierd way to do it, i think, and my problem its the page im
> trying to do its a template wich gives me a difentent line depending of
> $user i choose.
> The code i have so far its this:
> $filename = "http://localhost/all.php";;
> $fcontents = join('', file ($filename));
> $first = strstr ($fcontents, $user);
> $rest = substr ($first, 0, 108);
> wich works for example if $user = guessit , but if I use $user =
> Jim doenst
> work anymore cause "jim" its a word smaller than "guessit", and the limit
> 108 will give in that case characters of next line....
> heres part of the source of the page where im trying to grab lines :
> <tr><td>cow</td><td align=center>1</td><td align=center>54</td><td
> align=center>23</td><td align=center>77</td></tr>
> <tr><td>mer</td><td align=center>2</td><td align=center>44</td><td
> align=center>0</td><td align=center>44</td></tr>
> <tr><td>luis</td><td align=center>3</td><td align=center>40</td><td
> align=center>0</td><td align=center>40</td></tr>
> <tr><td>Flix</td><td align=center>4</td><td align=center>38</td><td
> align=center>7</td><td align=center>45</td></tr>
> <tr><td>Rulerman</td><td align=center>5</td><td align=center>35</td><td
> align=center>0</td><td align=center>35</td></tr>
> <tr><td>Jim</td><td align=center>6</td><td align=center>35</td><td
> align=center>13</td><td align=center>48</td></tr>
> <tr><td>guessit</td><td align=center>7</td><td align=center>35</td><td
> align=center>24</td><td align=center>59</td></tr>
> <tr><td>womo</td><td align=center>8</td><td align=center>34</td><td
> align=center>23</td><td align=center>57</td></tr>
> <tr><td>jay</td><td align=center>9</td><td align=center>4</td><td
> align=center>4</td><td align=center>8</td></tr>
> As u can see, "guessit" line is 4 characters longer than "jim" and the 108
> limit wil give me in case of jim line 4 chars of next line.

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to