whats wrong in this program.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$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.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux