retrieve data from text file (blank lines)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prue_
Forum Commoner
Posts: 64
Joined: Thu May 07, 2009 10:34 pm

retrieve data from text file (blank lines)

Post by prue_ »

(Edited: I believe I'm on the right topic now)
I want to put a validation for blank line.. the code I created read data from text file line by line using fgets.. I want to show the text "Not available" if there's a blank line... I tried the ff:

Code: Select all

if (empty($variable))
if ($variable==NULL)
if ($variable =="")
if ($variable =="\r\n")
 
NULL and "" don't work

though if ($variable =="\r\n") and if (empty($variable)) works, it replaces everything because all data have spaces, tabs, etc..... what if i only want to read "blank line" only?? (between name 3 and name 4)
(e.g. from text file)
name1
name2
name3

name4

can you give me an idea on this? thanks in advance.... any idea will be very much appreciated
Last edited by prue_ on Fri Sep 04, 2009 6:48 am, edited 2 times in total.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: scroll text from external text file

Post by Ollie Saunders »

This forum is call "PHP - Code" and you just posted a load of JavaScript without any PHP.
Post Reply