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