I have the following list of words (myfile.txt
) which I want to display
using PHP:
word1
#word2
word3
What I want to do is to skip those lines that start with # above.
Below is the PHP code I used to display the words. But I don't know how to skip the # word.
<?php
$fp = fopen('myfile.txt','r');
if($fp){
while(!feof($fp)){
$name = fgets($fp);
$name = rtrim($name);
$value = urlencode($name);
if(strlen($name) > 0){
echo "<option value=$value>$name</option>";
}
}
}
?>
</select>
</td>
What's the way to achieve that?