RE: [PHP-ES] transfortmar un numero a string
| From: | Christian Martiniera | Date: | Thu, 21 Dec 2000 19:12:03 +0000 |
| Subject: | RE: [PHP-ES] transfortmar un numero a string | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-5170@lists.php.net to get a copy of this message | ||
Para convertir
settype (string var, string type)
Los valores posibles para type son:
"integer"
"double"
"string"
"array"
"object"
Usa esta, es mas rapida!!
$numero = 1;
$container = "1,2,3,4";
// in PHP 4.0b3 and newer:
$pos = strpos ($container, settype ($numero, "string"));
if ($pos === false) { // note: three equal signs
// not found...
}
// in versions older than 4.0b3:
$pos = strpos ($container, settype ($numero, "string"));
if (is_string ($pos) && !$pos) {
// not found...
}
-----Mensaje original-----
De: Juan Icaza [mailto:juan@panamacom.com]
Enviado el: Viernes, 22 de Diciembre de 2000 05:06 a.m.
Para: lista@phpes.com
Asunto: [PHP-ES] transfortmar un numero a string
hola listeros
tengo una pregunta
tengo una variable que tiene un tipo de dato numero
y tengo una cadena con un listado de numeros y quiero saber si el numero
tiene ocurrencia en la cadena de numeros
tengo este codigo:
<?
$numero = 1;
$container = "1,2,3,4";
if(strstr($container,$string)) {
echo "found it.";
} else {
echo "not found.";
}
pero siempre me sale not found
pero si pongo $numero = "1";
si me resulta
alguien sabe somo cambiar la variable de tipo numerica a string?
gracias de antemano
?>
---------------------------------------------------------------------
Archivo On-line: http://www.phpes.com/
Manual PHP en español: http://www.php.net/manual/es/
Para dar de baja la suscripción, mande un mensaje a:
lista-unsubscribe@phpes.com