Re: [PHP] Replacing 2 strings

2005-06-01 Thread W Luke
On 31/05/05, W Luke <[EMAIL PROTECTED]> wrote: > On 31/05/05, Murray @ PlanetThoughtful <[EMAIL PROTECTED]> wrote: > > > > > > > > function replace($string){ > > > preg_match("/^<\^([a-zA-Z]+?)_([a-zA-Z]+?)>/", $string, $matcharr); > > > $string = str_replace($matcharr[0], $matcharr[1]

Re: [PHP] Replacing 2 strings

2005-05-31 Thread W Luke
On 31/05/05, Murray @ PlanetThoughtful <[EMAIL PROTECTED]> wrote: > > > > > function replace($string){ > > preg_match("/^<\^([a-zA-Z]+?)_([a-zA-Z]+?)>/", $string, $matcharr); > > $string = str_replace($matcharr[0], $matcharr[1] . " " .$matcharr[2] > > . ":", $string); > > return

RE: [PHP] Replacing 2 strings

2005-05-31 Thread Murray @ PlanetThoughtful
> > function replace($string){ > preg_match("/^<\^([a-zA-Z]+?)_([a-zA-Z]+?)>/", $string, $matcharr); > $string = str_replace($matcharr[0], $matcharr[1] . " " .$matcharr[2] > . ":", $string); > return $string; > > } > > $string = "<^JIM_JONES> Leicester, 1720. Oxford, 1800 CON

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Murray @ PlanetThoughtful
> > function replace($string, $search) > { > $string = strstr($string, $search) > $string = preg_replace("/(<|\^|>)/", "",$string); > $string = str_replace("_", " ", $string); > return $string; > > } > > $text = 'My name is <^JIM_JONES> and I like ice cream'; > $

Re: [PHP] Replacing 2 strings

2005-05-30 Thread Brian V Bonini
On Mon, 2005-05-30 at 16:24, W Luke wrote: > On 30/05/05, Brian V Bonini <[EMAIL PROTECTED]> wrote: > > [...] > > > > Again, an example that is as close to your real-world needs as possible > > > would be very helpful. > > > > The original request was: "the text-to-replace is just in a var named

Re: [PHP] Replacing 2 strings

2005-05-30 Thread W Luke
On 30/05/05, Brian V Bonini <[EMAIL PROTECTED]> wrote: [...] > > Again, an example that is as close to your real-world needs as possible > > would be very helpful. > > The original request was: "the text-to-replace is just in a var named > $text1". > > I read that to mean you'd already extracte

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Brian V Bonini
On Mon, 2005-05-30 at 15:24, Murray @ PlanetThoughtful wrote: > > This is a great help, thanks to both. One question I have though. > > How do I just leave the formatting "as is"? In the loop you gave me, > > Brian...: > > [snippage] > > > I can't see how I can disregard strtolower without dis

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Murray @ PlanetThoughtful
> This is a great help, thanks to both. One question I have though. > How do I just leave the formatting "as is"? In the loop you gave me, > Brian...: [snippage] > I can't see how I can disregard strtolower without disrupting the rest > of the function! My problem is $string contains a whole

Re: [PHP] Replacing 2 strings

2005-05-30 Thread W Luke
On 30/05/05, Brian V Bonini <[EMAIL PROTECTED]> wrote: > On Mon, 2005-05-30 at 11:13, Murray @ PlanetThoughtful wrote: > > > Someone much more clever that I can probably come up with something much > > > cleaner and efficient but This works... > > > > Definitely not more clever and arguably not

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Brian V Bonini
On Mon, 2005-05-30 at 12:58, Murray @ PlanetThoughtful wrote: >$string = "this"; > $string{0} = strtoupper($string{0}); > echo $string; // should return value of "This" > ?> I knew you could access but I didn't realize your could assign/replace specific chars like that, i.e. $string{x} =

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Murray @ PlanetThoughtful
> AHHH! ucwords(); I probably looked right at it a million times.. I knew > there had to be something to do that Lol, I know that feeling well! One thing, btw, looking at the solution you provided. Once you'd preg_split()ed the string into component words, you could have simply applied strtou

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Brian V Bonini
On Mon, 2005-05-30 at 11:13, Murray @ PlanetThoughtful wrote: > > Someone much more clever that I can probably come up with something much > > cleaner and efficient but This works... > > Definitely not more clever and arguably not more efficient, but a different > way of handling this might be

RE: [PHP] Replacing 2 strings

2005-05-30 Thread Murray @ PlanetThoughtful
> Someone much more clever that I can probably come up with something much > cleaner and efficient but This works... Definitely not more clever and arguably not more efficient, but a different way of handling this might be: )/", "",$string); $string = str_replace("_", " ", $string); $stri

Re: [PHP] Replacing 2 strings

2005-05-30 Thread W Luke
On 30/05/05, Brian V Bonini <[EMAIL PROTECTED]> wrote: > On Sun, 2005-05-29 at 12:22, W Luke wrote: > > Hi, > > > > I have some text in a file which, when it's dumped to a var, needs to > > be replaced. In its raw form, it looks like this: <^JIM_JONES> and I > > need to remove the <^_ and > charac

Re: [PHP] Replacing 2 strings

2005-05-29 Thread Brian V Bonini
On Sun, 2005-05-29 at 12:22, W Luke wrote: > Hi, > > I have some text in a file which, when it's dumped to a var, needs to > be replaced. In its raw form, it looks like this: <^JIM_JONES> and I > need to remove the <^_ and > characters and have it read "Jim-Jones" > > It's nestled in amongst a l

[PHP] Replacing 2 strings

2005-05-29 Thread W Luke
Hi, I have some text in a file which, when it's dumped to a var, needs to be replaced. In its raw form, it looks like this: <^JIM_JONES> and I need to remove the <^_ and > characters and have it read "Jim-Jones" It's nestled in amongst a load of other text - I'm fopen'ing a file and reading it l