Re: Text Parser
| From: | Daniel Schierbeck | Date: | Wed, 24 Nov 2004 19:46:22 +0000 |
| Subject: | Re: Text Parser | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202792@lists.php.net to get a copy of this message | ||
Jesse Castro wrote:
[snip] I need to get a procedure able to do this: 1) Receive a string. For example: "name age address location". 2) Process that string, inserting "comas" between the words in the middle. For example: "name,age,address,location". It´s important that the comas must be inserted after the first word, and before the last one. 3) Return that string. [/snip] $old = "name age address location"; $new = str_replace(" ", ",", $old); Why not go with 4 strings? If the string is like this it won't work as intended:$string = 'John Doe Fooroad 11 35 US'; // John,Doe,Fooroad,11,35,US -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/register&r=6584