mejora
| From: | José A Bermúdez | Date: | Wed, 23 Jul 2008 15:04:31 +0000 |
| Subject: | mejora | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-45159@lists.php.net to get a copy of this message | ||
Cris:
Hi.
The improvement to your function, proposed by Sanjay Mantoor, works
excellent. There´s no need to find any other way.
Bermúdez.
<?php
//here we use the function you proposed, improved by Sanjay Mantoor:
function return_int($value){
if (ctype_digit($value))
{
echo $value."\t";
return true;
}
else
{
return false;
}
}
?>
<?php
//First, we get the string from the a form:
$num=$_POST['the_string'];
//now we construct an array with characters in the string:
$value = str_split($num);
//here we filter the array looking for........ you know:
$value_new = array_filter($value, "return_int");
//This programming exercise comes from an eMail I recived yerterday.
//How can I find the integers inside a string?
//The original an a good answer are in the folder of the site. Read
it!
//Wednesday, july 23th, 2008.
?>