[thelist] Using PHP to write CSS

Ron Dorman rwd at csi1st.net
Mon May 20 15:13:01 CDT 2002


Burhan Khalid wrote:

> [ snip ]
>
>>would something like this help you?
>>
>>$body = str_replace("%uname%", $uname, $body);
>>
>>%uname% = string in file to be replaced
>>$uname  = php variable to replace the string
>>$body   = the file to search and replace in
>>
>>
> [ /snip ]
>
> I am assuming that the $body in this example is all of the text in a file. I
> am trying to avoid reading the entire file in order to replace just one
> thing.
> Seems kinda cumbersome to have to read everything, store it, search &
> replace, write it back. What I would like to be able to do is just use the
> following information :
>
> 1. string to look for
> 2. where to look for it (file name)
> 3. what to replace it with
>
> and have PHP "scan" the file (without having to store it as a variable in my
> script), replace the text, save the file, so that I can include it.


You can do that with a 'grep' command on *nix systems or a script on Win
systems.  Maybe have your php generate the needed grep cmd/win script
and then execute at the system command level.

Ron D.




More information about the thelist mailing list