you could do it like so, also:

<?
$str = "Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6";

while ( strstr(";;", $str) )  ## if exists ;; in $str, replace with 1 ;
 $str = str_replace( ";", $str );
?>

works for ya, I hope.

peaces,

-----
Nicole Amashta
Web Application Developer
www.aeontrek.com


"Ross Fleming" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Sorry, but neither of these suggestions work on my server, and it would
> probably run into problems if one of the "Mot"s had a _ at the beginning
or
> end.  Nicola's first offering gives:
> Mot1_;Mot2_;_;_;_;_;_;_;_Mot3_;_;_;Mot4_;_;_;_;_Mot5_;_;Mot6
>
> The second one gives:
> Mot1;Mot2;;;;;;;_Mot3;;;Mot4;;;;_Mot5;;Mot6
>
> My solution?  Recursively replace ";;" with ";" until the string doesn't
get
> any shorter.  This one works and is pretty neat:
>
>
> <?
> $str = "Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6";
>
> $length=-1;
>
> while ($length != strlen($str)) {
>   $length = strlen($str);
>   $str = str_replace(";;", ";", $str);
> }
>
> echo $str;
> ?>
>
> Returns:
> Mot1;Mot2;Mot3;Mot4;Mot5;Mot6
> as required
>
> Regards
>
> Ross
>
> -----Original Message-----
> From: Nicola Delbono [mailto:[EMAIL PROTECTED]]
> Sent: 12 April 2002 18:31
> To: Matt Babineau
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP-WIN] String reduce
>
>
>
> I added the underscore artificially in order to make the string become
>
> Mot1_;__;_Mot2_;__;__;__;__;__;__;__;__;__;_Mot3_;__;__;_andsoon;;;M
> ot4;;;;;;;Mot5;;;;Mot6
>
> so ONLY the first(s) ";" begin with just ONE underscore
> the other  begins with 2 underscores, so you can recognize them
> and strip them away.
>
>
>
> the correct version would be
>
> $str = "Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6";
> $str = str_replace(";", "_;_", $str);
> $str = str_replace("__;_", "", $str);
> $str = str_replace("_;", ";", $str);
>
>
> The string is:
> Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6
>
> then becomes
> $str = str_replace(";", "_;_", $str);
>
> Mot1_;__;_Mot2_;__;__;__;__;__;__;__;__;__;_Mot3_;__;__;_andsoon;;;M
> ot4;;;;;;;Mot5;;;;Mot6
>
> then becomes
> $str = str_replace("__;_", "", $str);
> Mot1_;Mot2_;Mot3_;Mot4_;Mot5_;Mot6
>
> then becomes
> $str = str_replace("_;", ";", $str);
> Mot1;Mot2;Mot3;Mot4;Mot5;Mot6
>
>
> It's horrible but it works... ( yet I didn't test it )
>
>
> Bye
>
>
>
>
> *********** REPLY SEPARATOR  ***********
>
> On 12/04/2002 at 12.50 Matt Babineau wrote:
>
> >What does the underscore do in this situation?
> >
> >-----Original Message-----
> >From: Nicola Delbono [mailto:[EMAIL PROTECTED]]
> >Sent: Friday, April 12, 2002 12:43 PM
> >To: Kriegers Horst; 'PHP-Windows'
> >Subject: Re: [PHP-WIN] String reduce
> >
> >
> >
> >try
> >$str = "Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6";
> >$str = str_replace(";", "_;_", $str);
> >$str = str_replace("__;_", "", $str);
> >
> >:-D
> >
> >
> >
> >
> >
> >
> >*********** REPLY SEPARATOR  ***********
> >
> >On 12/04/2002 at 16.10 Kriegers Horst wrote:
> >
> >>Hi all,
> >>
> >>how can I replace the n ; with only one
> >>
> >>Mot1;;Mot2;;;;;;;;;;;;;Mot3;;;;;;Mot4;;;;;;;Mot5;;;;Mot6
> >>==>
> >>Mot1;Mot2;Mot3;Mot4;Mot5;Mot6
> >>
> >>So that I can explode it in an array.
> >>
> >>Thanks for your help
> >>Horst
> >>
> >>
> >>
> >>--
> >>PHP Windows Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> >dr. Nicola Delbono
> >[EMAIL PROTECTED]
> >Key5 di Delbono Nicola
> >V. G.M. Rossi, 12
> >25038 Rovato (Bs)
> >Tel 39 030 7242266
> >Fax 39 030 7242266
> >
> >www.smscitta.com | www.musicalbox.it
> >www.filosofo.it | www.bollicine.com
> >
> >
> >--
> >PHP Windows Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> dr. Nicola Delbono
> [EMAIL PROTECTED]
> Key5 di Delbono Nicola
> V. G.M. Rossi, 12
> 25038 Rovato (Bs)
> Tel 39 030 7242266
> Fax 39 030 7242266
>
> www.smscitta.com | www.musicalbox.it
> www.filosofo.it | www.bollicine.com
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to