From: "Jerry Lake" <[EMAIL PROTECTED]>
> I've tried and tried to no avail, can someone assist
> I need to select the first space in a line like the following
> Nelson Bob and Mary, 123 Street st., Ashton, 555-1212
>
> I need to replace the space between Nelson and Bob with
> a comma so I can separate the first and last names in my DB
> ^\D*\s will select the first name and the space, but I just
> need the space. any ideas?
>
<?php
$str = "Nelson Bob and Mary, 123 Street st., Ashton, 555-1212";
$str = ereg_replace("^([^ ]+) (.+)", "\\1, \\2", $str);
?>
Or alternatively:
<?php
$str = "Nelson Bob and Mary, 123 Street st., Ashton, 555-1212";
$str_bits = explode(" ", $str);
$str_bits[0] .= ",";
$str = implode(" ", $str_bits);
?>
Cheers
Simon Garner
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]