Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Friday teaser , otherwise known as fputs() - useful example please

Status
Not open for further replies.

KarveR

MIS
Dec 14, 1999
2,065
GB
Hi all, currently I'm trying to write to a file (which is going rather well :))

However I need to be accurate with where I place certain pieces of data and from looking at the PHP docs fput() looks like the thing to use.

The PHP.net docs on fput are either far too complex for me, or a little vague.
fputs
(PHP 3, PHP 4 >= 4.0.0)

fputs -- Writes to a file pointer
Description
int fputs ( int fp, string str [, int length])

so can anyone give me a fine example that really shows me whats what here please?
e.g
$myname=&quot;karver-and-im-abit-dim&quot;; <-max length is 8 character, how would I get this to appear at character 15(i.e 15 blank spaces before it)on a line and not be longer than 8 characters.
->
int fputs ( int fp, string str [, int length])
<-
***************************************
Party on, dudes!
 
i'm not sure, but try this:

fseek($fp,15,SEEK_CUR); // se the manual for the other flags.
fputs($fp,sprintf(&quot;%8s&quot;,$var),8); Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Thnaks Anikin I'll try that when I get up later ;) ***************************************
Party on, dudes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top