smerny Posted June 6, 2009 Share Posted June 6, 2009 $birthdate is in the format of YYYY-MM-DD $byear = strtok($birthdate, "-"); $bmonth = strtok("-"); $bday = strtok("-"); I was thinking this would work based on the w3 tutorial which says: <?php$string = "Hello world. Beautiful day today.";$token = strtok($string, " ");while ($token != false) { echo "$token<br />"; $token = strtok(" "); } ?> The output of the code above will be:Helloworld.Beautifuldaytoday. I am getting null values, what am I doing wrong? Link to comment Share on other sites More sharing options...
danm68 Posted June 6, 2009 Share Posted June 6, 2009 Is $birthdate a string? Does $birthdate have a value? Or is it empty?Just tried the code below and it works like a charm.. $birthdate = "2009-06-06"; $byear = strtok($birthdate, "-"); $bmonth = strtok("-"); $bday = strtok("-"); echo "Year: $byear<br />"; echo "Month: $bmonth<br />"; echo "Day: $bday"; Check and see what format $birthdate is being stored in. Link to comment Share on other sites More sharing options...
smerny Posted June 6, 2009 Author Share Posted June 6, 2009 ok i had a typo in calling the variable from the database Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.