whats wrong in this program.
| From: | babu | Date: | Wed, 14 Sep 2005 00:16:08 +0000 |
| Subject: | whats wrong in this program. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-222316@lists.php.net to get a copy of this message | ||
$str=10,12,14-18;
$tok = strtok($str, ',');
while ($tok !== false) {
$toks[] = $tok;
$tok = strtok(',');
}
foreach ($toks as $token){
if (strpos($token,'-')){
stringtokenize($token);
}else{
$finaltokens[]= $token;
}
}
function stringtokenize($nstr){
$ntok1= strtok($nstr,'-');
$ntok2=strtok('-');
for($i=$ntok1;$i<=$ntok2;$i++){
$finaltokens[]= $i;
}
}
foreach ($finaltokens as $ftoken){
echo $ftoken;
echo "<br />";
}
the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem.
---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.