Re: concatenar espacios en blanco
| From: | Satyam | Date: | Thu, 29 Apr 2004 21:06:37 +0000 |
| Subject: | Re: concatenar espacios en blanco | ||
| References: | 1 2 3 4 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-48138@lists.php.net to get a copy of this message | ||
Cierto, perdon.
----- Original Message -----
From: "Josep Maria Aribau Cano" <jm@infodos.com>
To: "Satyam" <Satyam@satyam.com.ar>; <php-es@lists.php.net>
Sent: Friday, April 30, 2004 5:34 AM
Subject: RE: [PHP-ES] concatenar espacios en blanco
> Si ves el codigo fuente de la pagina resultante, aparece espacios ( no
> que los he quitado con unhtmlentities) normales que no se ni cómo
> quietarlos. La versión de PHP es 4.2.0.
>
> A ustedes tambien les passa?
>
> ----- Original Message -----
> From: Satyam <Satyam@satyam.com.ar>
> To: Josep Maria Aribau Cano <jm@infodos.com>; <php-es@lists.php.net>
> Sent: Thursday, April 29, 2004 12:59 PM
> Subject: Re: [PHP-ES] concatenar espacios en blanco
>
>
> > Mira en binario qué caracter es. Tabulacion no ha de ser, pues ya
> entraria
> > dentro del \s, pero, si fuera HTML, un que se muestra como
blanco.
> > Entonces usa la cadena de busqueda correspondiente a los caracteres que
> > fueran. De no ser por eso, tampoco lo entiendo.
> >
> > Satyam
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Josep Maria Aribau Cano" <jm@infodos.com>
> > To: <php-es@lists.php.net>
> > Sent: Friday, April 30, 2004 1:39 AM
> > Subject: RE: [PHP-ES] concatenar espacios en blanco
> >
> >
> > > Agradeceros a todos las respuestas que me habeis enviado, i casi lo
> tengo
> > un
> > > resuelto a no ser por ciertos espacios que no hay forma de quitarlos.
> > >
> > > Estoy usando este código para concatenar espacios en blanco de la
pagina
> > > www.aquarius.es/meteo
> > > pero aún hay espacios que no se quitan ni usando el código de Xavier
> Serna
> > > ni el de Antonio J. Hdez
> > >
> > > El resultado es este:
> > > METEO & WEBCAM Datos actuales en Camping Aquarius (Playa de Sant
Pere
> > > Pescador) Fecha: 29 abr 2004 Hora Datos: 18:27:14 (GMT+1) Temperatura
> > > Presión Humedad Velocidad del viento Dirección del viento ºC ºF hPa %
> m/s
> > > Km/h kt Beaufort W Ponent 14,5 58,1 996 89 0,88 3,2
2
> 1
> > > Ultimas 24 h: grafica
> > > (hay spacios antes i despúes de la serie de numeros)
> > >
> > >
> > > Aqui teneis el código:
> > > <?php
> > > function unhtmlentities ($string) {
> > > $trans_tbl = get_html_translation_table (HTML_ENTITIES);
> > > $trans_tbl = array_flip ($trans_tbl);
> > > $ret = strtr ($string, $trans_tbl);
> > > return $ret;
> > > }
> > >
> > > $filename =
> > > 'http://www.aquarius.es/meteo/';
> > > $fd = fopen ($filename, 'r');
> > > $contents = fread ($fd, 10240);
> > > fclose ($fd);
> > > $sinhtml = strip_tags ($contents);
> > > $sinhtml = unhtmlentities($sinhtml);
> > >
> > > /*
> > > $sinhtml = str_replace("\r"," ",$sinhtml);
> > > $info = explode(' ',$sinhtml);
> > > while (list($key,$value)=each($info)) {
> > > if (trim($value)) $final.= ' '.$value;
> > > }
> > > echo($final);
> > > */
> > >
> > > $original=preg_replace("/\s{2,}/"," ",$sinhtml);
> > > echo $original
> > >
> > > ?>
> > >
> > >
> > > ----- Original Message -----
> > > From: Antonio J. Hdez. Blanco <chino@dlsi.ua.es>
> > > To: <php-es@lists.php.net>
> > > Sent: Thursday, April 29, 2004 11:14 AM
> > > Subject: Re: [PHP-ES] concatenar espacios en blanco
> > >
> > >
> > > >
> > > > $original=preg_replace("/\s{2,}/"," ",$original);
> > > >
> > > > \s -> asi elimina espacios en blancos, \t\n\r y otros
> > > >
> > > > ----- Original Message -----
> > > > From: "Antonio J. Hdez. Blanco" <chino@dlsi.ua.es>
> > > > To: "Xavier Serna" <xserna@justedit.es>
> > > > Sent: Thursday, April 29, 2004 5:56 PM
> > > > Subject: Re: [PHP-ES] concatenar espacios en blanco
> > > >
> > > >
> > > > >
> > > > > $original=ereg_replace("\t{2,}"," ",$original);
> > > > >
> > > > > funciona si los espacios son echos con tab :(
> > > > >
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Xavier Serna" <xserna@justedit.es>
> > > > > To: <php-es@lists.php.net>
> > > > > Sent: Thursday, April 29, 2004 11:45 AM
> > > > > Subject: Re: [PHP-ES] concatenar espacios en blanco
> > > > >
> > > > >
> > > > > > Con expresiones regulares seguramente se podrá hacer, pero como
yo
> > no
> > > > > > controlo, con este código también se consigue lo que quieres,
> aunque
> > > no
> > > > es
> > > > > > demasiado óptimo...
> > > > > >
> > > > > > <?
> > > > > > echo "<pre>\r\n";
> > > > > > $original = "Hola como estas
> > > > hoy?";
> > > > > > echo $original."\r\n";
> > > > > >
> > > > > > $destino = explode(" ",$original);
> > > > > > while (list($key,$value)=each($destino))
> > > > > > if (trim($value)) $final .= " ".$value;
> > > > > >
> > > > > > echo trim($final)."\r\n";
> > > > > > echo "<pre/>";
> > > > > > ?>
> > > > > >
> > > > > > saludos
> > > > > > Xavi
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Josep Maria Aribau Cano" <jm@infodos.com>
> > > > > > To: <>
> > > > > > Sent: Thursday, April 29, 2004 18:37
> > > > > > Subject: [PHP-ES] concatenar espacios en blanco
> > > > > >
> > > > > >
> > > > > > > Cómo convertir X espacios en blanco en sólo un espacio en
blanco
> > > > dentro
> > > > > de
> > > > > > > un string?
> > > > > > >
> > > > > > > Ex: Hola como estas hoy?
> > > > > > > Resultado: Hola cómo estas hoy?
> > > > > > >
> > > > > > > --
> > > > > > > PHP Spanish Localization Talk Mailing List
(http://www.php.net/)
> > > > > > > To unsubscribe, visit: lŠ
> > > > > > > ßX¶oœ¾reÓhttp://www.php.net/unsub.php
> > > > > > >
> > > > > > >
> > > > > >
> > > > > > --
> > > > > > PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> > > > > > To unsubscribe, visit:
> > > > > > http://www.php.net/unsub.php
> > > > > >
> > > > >
> > > >
> > > > --
> > > > PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > >
> > > --
> > > PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> > --
> > PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>