How to select a line from a web page source?

From: Date: Tue, 10 Jul 2001 23:20:05 +0000
Subject: How to select a line from a web page source?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57262@lists.php.net to get a copy of this message
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. Is there a easier way to select a line? Or if this is the only way, is there a way i can set MySQL fields to have the same chars size, for example 20, even the text if smaller? That would solve the problem too, cause that way all lines would be equal :) ty guys

« previous php.general (#57262) next »