ID: 9302
Updated by: stas
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Strings related
Assigned To: 
Comments:

Not a bug. Scanf delimits strings by whitespace, not by
arbitrary symbol. Use [pe]reg_match or split if you need to
delimit by arbitrary symbol.

Previous Comments:
---------------------------------------------------------------------------

[2001-02-19 03:04:39] [EMAIL PROTECTED]
That's an error in function sscanf. The next code don´t works properly:

<?php
 // este script es una prueba del scanf
 $str="hola;esto;es;una;prueba";
 $a="";
 $b="";
 $c="";
 $d="";
 $e="";
 sscanf($str,"%s;%s;%s;%s;%s",&$a,&$b,&$c,&$d,&$e);
 echo $a.$b.$c.$d.$e;
 ?>
 
 the ouput would be:
 
 hola;esto;es;una;prueba
 
 If we use the next code, output would be correct:


<?php
 // este script es una prueba del scanf
 $str="hola ; esto ; es ; una ; prueba";
 $a="";
 $b="";
 $c="";
 $d="";
 $e="";
 sscanf($str,"%s ; %s ; %s ; %s ;
 %s",&$a,&$b,&$c,&$d,&$e);
 echo $a.$b.$c.$d.$e;
 ?>
 
 And the output would be:
 
 holaestoesunaprueba
 
the function sscanf is unable to read the string under an especified format.

PD: When a bug report's section at your site written in Spanish??? It isn't so 
difficult, jani.


---------------------------------------------------------------------------

[2001-02-18 16:29:33] [EMAIL PROTECTED]
Use english ONLY when submitting bug reports.

--Jani


---------------------------------------------------------------------------

[2001-02-16 11:13:03] [EMAIL PROTECTED]
 Hay un error en la funcion sscanf ya que no realiza
 la lectura de datos segun el formato especificado.
 Por ejemplo, consideremos el siguiente codigo:
 
 <?php
 // este script es una prueba del scanf
 $str="hola;esto;es;una;prueba";
 $a="";
 $b="";
 $c="";
 $d="";
 $e="";
 sscanf($str,"%s;%s;%s;%s;%s",&$a,&$b,&$c,&$d,&$e);
 echo $a.$b.$c.$d.$e;
 ?>
 
 La salida seria la siguiente:
 
 hola;esto;es;una;prueba
 
 Por el contrario si usamos el siguiente
 formato:
 
 <?php
 // este script es una prueba del scanf
 $str="hola ; esto ; es ; una ; prueba";
 $a="";
 $b="";
 $c="";
 $d="";
 $e="";
 sscanf($str,"%s ; %s ; %s ; %s ;
 %s",&$a,&$b,&$c,&$d,&$e);
 echo $a.$b.$c.$d.$e;
 ?>
 
 la salida es correcta:
 
 holaestoesunaprueba
 
 Se ve que la funcion sólo respeta
 el formato si las zonas donde se
 indica que comienza una variable 
 (en el codigo %(tipo_de_variable))
 esta aislada, es decir, separada
 con espacios del resto de los
 caracteres del formato.
 
He realizado varias pruebas de lectura bajo
formatos especificos y no consigo que 
la funcion responda segun las especificaciones.


 Saludos desde cordoba
 


---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9302&edit=2


-- 
PHP Development 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]

Reply via email to