fwrite() help needed

This is a discussion on fwrite() help needed within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am trying to write to a .rtf file form a php page. I can create a temp rtf file ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-18-2003
Craig Keightley
 
Posts: n/a
Default fwrite() help needed

I am trying to write to a .rtf file form a php page.
I can create a temp rtf file based on a template but i can only change one
item on the page.
I want to be able to change multiple items in the rtf file based on what has
been entered in the html page

eg

the rtf file has [[name]] [[address]] [[phone]]

I can use the str_replace to change one item but not all three
any suggestions?

Craig


Reply With Quote
  #2 (permalink)  
Old 09-18-2003
Gary Petersen
 
Posts: n/a
Default Re: fwrite() help needed

On Thu, 18 Sep 2003 09:22:01 -0500, Craig Keightley created an
award-winning crop circle <3f69bf8a$0$254$cc9e4d1f@news.dial.pipex.com>,
which, when translated into English, means this:

> I am trying to write to a .rtf file form a php page. I can create a temp
> rtf file based on a template but i can only change one item on the page.
> I want to be able to change multiple items in the rtf file based on what
> has been entered in the html page
>
> eg
>
> the rtf file has [[name]] [[address]] [[phone]]
>
> I can use the str_replace to change one item but not all three any
> suggestions?
>
> Craig


Perhaps you need three invokations of str_replace.
All of the invokations should operate on the same
string.

Reply With Quote
  #3 (permalink)  
Old 09-19-2003
Nikolai Chuvakhin
 
Posts: n/a
Default Re: fwrite() help needed

"Craig Keightley" <craig@sitedesign.net> wrote in message
news:<3f69bf8a$0$254$cc9e4d1f@news.dial.pipex.com> ...
>
> the rtf file has [[name]] [[address]] [[phone]]
>
> I can use the str_replace to change one item but not all three


But of course you can change all three:

$rtf = 'the rtf file has [[name]] [[address]] [[phone]]';
$rtf = str_replace ('[[name]]', 'Craig Keightley', $rtf);
$rtf = str_replace ('[[address]]', 'craig@sitedesign.net', $rtf);
$rtf = str_replace ('[[phone]]', '(987)654-3210', $rtf);

Now $rtf should read like this:

the rtf file has Craig Keightley craig@sitedesign.net (987)654-3210

Cheers,
NC
Reply With Quote
  #4 (permalink)  
Old 09-19-2003
Dmitry Ruban
 
Posts: n/a
Default Re: fwrite() help needed

Hey Craig,

try this

$search = array ( "[[name]]", "[[address]]", "[[phone]]" );
$replace = array ( "My Name", "My Address", "My Phone" );
$rtf = str_replace ( $search, $replace, $rtf );

that's it

Dima

"Craig Keightley" <craig@sitedesign.net> wrote in message
news:3f69bf8a$0$254$cc9e4d1f@news.dial.pipex.com.. .
> I am trying to write to a .rtf file form a php page.
> I can create a temp rtf file based on a template but i can only change one
> item on the page.
> I want to be able to change multiple items in the rtf file based on what

has
> been entered in the html page
>
> eg
>
> the rtf file has [[name]] [[address]] [[phone]]
>
> I can use the str_replace to change one item but not all three
> any suggestions?
>
> Craig
>
>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:55 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0