On Mon, 2005-05-30 at 16:24, W Luke wrote: > On 30/05/05, Brian V Bonini <b-bonini@xxxxxxx> 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 extracted "<^JIM_JONES>" into $text1 > > Sorry - my mistake/fault. $text1 always begins with <^JIM_JONES> by > is followed by various other stuff: > > <^JIM_JONES> Leicester, 1720. Oxford, 1800 CONFIRMED: meeting at 19.10 > > And I'd like it to read, simply, JIM JONES: (I think having the name > in Caps would be best for now) and leave the rest of the text > unaltered: <?php // this will produce Jim-Jones as in previous post function replace($string, $search) { $string = strstr($string, $search) $string = preg_replace("/(<|\^|>)/", "",$string); $string = str_replace("_", " ", $string); $string = ucwords(strtolower($string)); $string = str_replace(" ", "-", $string); return $string; } $text = 'My name is <^JIM_JONES> and I like ice cream'; $search_string = '<^JIM_JONES>'; echo replace($text, $search_string); ?> <?php // this will produce JIM JONES 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'; $search_string = '<^JIM_JONES>'; echo replace($text, $search_string); ?> -- s/:-[(/]/:-)/g Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu ====================================================================== gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php