Re: Re: Question about string replace -PHP

From: Date: Tue, 14 May 2002 22:10:10 +0000
Subject: Re: Re: Question about string replace -PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97629@lists.php.net to get a copy of this message
On Wednesday 15 May 2002 05:20, Josh & Valerie McCormack wrote: > I didn't ask the question about this, but I have a related issue. I'm > trying to do a replace, and am using str_replace, but the outcome is not > what I expected. > > Here's my code: > > <? > $fp = fopen("new_data.csv", "r"); > $text = fopen("text.txt", "r"); > $merged = fopen("merged_text.html", "w"); > $filecontents = fread($text,filesize("text.txt")); > while ($data = fgetcsv ($fp, 1000, ",")) { > $num = count ($data); > $fullname = $data[0] . ' ' . $data[1]; > $newfullname = '123 ' . $fullname . ' 456'; Remove the above line, it's superfluous. > $filecontents = str_replace($fullname, "123 $fullname 456", $filecontents); [snip] > I only want it to have one set of 123 and 456 on either side. Any ideas? -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "There is no distinctly American criminal class except Congress." -- Mark Twain */

« previous php.general (#97629) next »